Created
April 18, 2022 20:49
-
-
Save rochacbruno/e652c090151754d47d7bf28005b4397d to your computer and use it in GitHub Desktop.
curses detect key pressed python - detect each types key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import curses | |
import os | |
def main(win): | |
win.nodelay(True) | |
key = "" | |
win.clear() | |
win.addstr("Detected key:") | |
while True: | |
try: | |
key = win.getkey() | |
win.clear() | |
win.addstr("Detected key:") | |
win.addstr(str(key)) | |
if key == os.linesep: | |
break | |
except Exception: | |
# No input | |
pass | |
curses.wrapper(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment