Single key press

Nobody nobody at nowhere.com
Tue Dec 6 04:48:55 EST 2011


On Tue, 06 Dec 2011 10:19:55 +0430, Sergi Pasoev wrote:

> I wonder if it is realistic to get a single key press in Python
> without ncurses or any similar library.

On Unix, you need to use termios.tcsetattr() to disable "canonical mode".
Otherwise, the tty driver will only pass data up to the application when
the user enters a newline or EOF.

If you do this, you also need to handle SIGTSTP and SIGCONT, restoring the
original terminal settings on SIGTSTP (typically generated by Ctrl-Z) and
restoring the application's setting on SIGCONT.




More information about the Python-list mailing list