How to get Ctrl, Shift or Alt with getch() ncurses?

后端 未结 7 1441
挽巷
挽巷 2020-12-10 03:11

How to get Ctrl, Shift or Alt with getch() ncurses ?
I cannot get it work to get Ctrl, Shift or

7条回答
  •  借酒劲吻你
    2020-12-10 03:46

    (To roughly copy my answer from How to get Shift+X / Alt+X keys in Curses ?)

    Long story short - you cannot. The modifier keys are just that - modifiers. They do not exist in their own right, they modify some other (printing) key that you might press.

    That said, if you are feeling especially brave, you can try my libtermkey which will at least correctly parse things like Ctrl-arrow.

    Finally if you're feeling even braver you can run the terminal I wrote, pangoterm, which has generic ways to encode any arbitrarily modified Unicode keys, so it can distinguish Ctrl-m from Enter, Ctrl-Shift-a from Ctrl-a, etc...

    However, outside of these, the answer remains "you cannot".

提交回复
热议问题