-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read keys persist there actions to the terminal #482
Comments
Yes, what you are looking for is "suppression" of events. Try But please keep in mind that this library is meant for global events. So the character will be captured even if it was pressed when the terminal was not focused. If you want to just capture a single key without outputting it, something like |
Ahh that is helpful, thank you! |
If it's just backspace and enter, you are in luck, those actually count as characters and are returned by getch:
What you cannot get are modifiers, like alt, shift, caps-lock, etc, and F1-F12 keys (they just report 0x00). Basically anything with its own ASCII code (and by extension present in Unicode), should work. |
Amazing, thank you @boppreh! |
You're welcome! I'm closing this ticket for now, and including a line about getch in the readme. Good luck in your project! |
(This may be related to issue #22)
Relating to this StackOverflow post: Using keyboard module persists key actions to the terminal
It seems that when reading keys using
read_key()
that (say for example a character key or the'Enter'
key is read) the action for that key will persist in the terminal later if, say, the built-ininput()
function is used.E.g. Pressing the, say,
q
key at an initial part of the program will later pre-populateinput()
with the characterq
when the user is next require to pass input. It would be nice if the read character fromread_key()
did not get sent to stdin or stdout.The text was updated successfully, but these errors were encountered: