Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #16714

Re: Single key press

From Nobody <nobody@nowhere.com>
Subject Re: Single key press
Date 2011-12-06 09:48 +0000
Message-Id <pan.2011.12.06.09.49.07.611000@nowhere.com>
Newsgroups comp.lang.python
References <mailman.3332.1323150597.27778.python-list@python.org>
Organization Zen Internet

Show all headers | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Single key press Sergi Pasoev <s.pasoev@gmail.com> - 2011-12-06 10:19 +0430
  Re: Single key press 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-05 22:27 -0800
  Re: Single key press 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-05 22:27 -0800
  Re: Single key press alex23 <wuwei23@gmail.com> - 2011-12-06 00:39 -0800
  Re: Single key press Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-06 08:48 +0000
    Re: Single key press Hans Mulder <hansmu@xs4all.nl> - 2011-12-06 10:28 +0100
  Re: Single key press Nobody <nobody@nowhere.com> - 2011-12-06 09:48 +0000
  Re: Single key press Grant Edwards <invalid@invalid.invalid> - 2011-12-06 15:22 +0000
    Re: Single key press 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-06 07:38 -0800

csiph-web