'How to check for ENTER key press in curses. curses.KEY_ENTER not working [duplicate]
I am trying to get user input in curses (python), and for some reason it cannot detect when I press the ENTER key.
while True:
key = stdscr.getkey()
if key == curses.KEY_ENTER:
TASK += 1
break
elif key.lower() == 'q':
quit(stdscr)
break
the if part is not working and the elif part is working fine.
Solution 1:[1]
curses.KEY_ENTER would be the numeric-keypad Enter key
- if curses
keypadmode is enabled and - if the terminal description has the corresponding code and
- if the terminal actually sends what the terminal description says. (Keypad coverage on some terminal emulators is an area for improvement).
It's not related to the Enter key on the main keyboard.
You'll get better results if you add a comparison for \n and \r (this is probably a duplicate).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Thomas Dickey |
