Check for keypress on Linux xterm ?

hlubenow hlubenow2 at gmx.net
Tue Apr 10 11:09:07 EDT 2007


Grant Edwards wrote:

> On 2007-04-09, hlubenow <hlubenow2 at gmx.net> wrote:
> 
>> My problem is, I don't want my program to wait for the keypress.
>> I just want to check, if a key is currently pressed and if not, I'd like
>> to continue with my program (like "INKEY$" in some BASIC-dialects).
> 
> The answer to this frequently asked question is actually in the FAQ:
> 
>
http://www.python.org/doc/faq/library.html#how-do-i-get-a-single-keypress-at-a-time
> 
> Google finds us further examples:
>  
>  http://mail.python.org/pipermail/pythonmac-sig/2004-February/010140.html
>  http://mail.python.org/pipermail/python-list/2000-June/041251.html

You're answer is only less than half correct:

Most of the given examples use something like

c = sys.stdin.read(1)

like my example does. This blocks input. At the end of your last link the
author there says it. He also shows some ways into my direction.
I'll test them.

H.



More information about the Python-list mailing list