John McKenzie <dav...@bellaliant.net> writes: > Would like a set-up where something happens when a key is pressed. Not > propose a question, have the user type something, then hit return, then > something happens, but just the R key is pressed, something happens,
The quick answer is that you want raw mode tty input. Type "stty raw" to the shell, and sys.stdin.read(1) will give you the bytes of the typed characters immediately. Use "stty -raw" to put it back in cooked mode, or maybe better, "stty sane" to restore normal settings in general. Yes there are messy details like function keys actually sending several characters. In practice you'll also want to control the tty modes from your program instead of the shell, but that should get you started. You may also want to turn off echo, i.e. "stty raw -echo". -- https://mail.python.org/mailman/listinfo/python-list