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


Groups > comp.lang.python > #16736

Re: Single key press

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!news-xxxfer.readnews.com!panix!not-for-mail
From Grant Edwards <invalid@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: Single key press
Date Tue, 6 Dec 2011 15:22:18 +0000 (UTC)
Organization PANIX Public Access Internet and UNIX, NYC
Lines 14
Message-ID <jblbv9$sl8$1@reader1.panix.com> (permalink)
References <mailman.3332.1323150597.27778.python-list@python.org>
NNTP-Posting-Host dsl.comtrol.com
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Trace reader1.panix.com 1323184938 29352 64.122.56.22 (6 Dec 2011 15:22:18 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Tue, 6 Dec 2011 15:22:18 +0000 (UTC)
User-Agent slrn/pre0.9.9-102 (Linux)
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:16736

Show key headers only | View raw


On 2011-12-06, Sergi Pasoev <s.pasoev@gmail.com> wrote:

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

Yes.  Just put the tty associated with stdin in raw mode and make
single byte read() calls on it. Remember to restore the tty settings
when your program exits.

-- 
Grant Edwards               grant.b.edwards        Yow! World War III?
                                  at               No thanks!
                              gmail.com            

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