You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The cursor keys in application mode are not match the constants #124
https://tldp.org/HOWTO/Keyboard-and-Console-HOWTO-21.html
When the terminal is in application cursor key mode, the cursor keys produce Esc O x and otherwise Esc [ x where x is one of A, B, C, 'D`. Certain programs put the terminal in application cursor key mode; if you kill them with kill -9, or if they crash, then the mode will not be reset.
The key code constants only match the normal mode.
To fix this, I think the easiest way is to reset the cursor key mode to normal:
defreadkey() ->str:
"""Get a keypress. If an escaped key is pressed, the full sequence is read and returned as noted in `_posix_key.py`."""# Reset the terminal to normal cursor key mode# https://tldp.org/HOWTO/Keyboard-and-Console-HOWTO-21.htmlprint("\x1b[?1l", end='')
# It can be quite long when input is from IME.return_readkeybuffer(1000)
If you agree with me, I can create a PR or you can also use the above code directly.
I don't think pushing that onto every call to readkey() for every user is a good idea. When needed it can be added by applications on startup once, which is the much better solution.
There are development efforts to create a context-manager for this lib which would be a good place to add this code, but that is far of from beeing ready to be shipped and I don't have much time to work on it currently.
Activity
Cube707 commentedon Apr 5, 2025
I don't think pushing that onto every call to
readkey()for every user is a good idea. When needed it can be added by applications on startup once, which is the much better solution.There are development efforts to create a context-manager for this lib which would be a good place to add this code, but that is far of from beeing ready to be shipped and I don't have much time to work on it currently.
Cube707 commentedon Apr 6, 2025
this is somewhat related to #24