How can I catch key combinations like ALT+K or CTRL+ALT+H in python curses?
How can I catch key combinations like ALT + K or CTRL + ALT
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A terminal converts the control key in combination with a letter key to a normal ASCII code. This can be read from the getch() function like any other key press.
Also, the keypad() function must be called to enable other special function keys (e.g. left arrow, F1, home, etc).
I don’t believe there is a portable way to receive meta-keys (e.g. ALT-H) through a terminal. Some send an escape (0x1B) followed by the modified key while others set the high-bit and only send one byte.