Detecting key presses

Fan Zhang yalexfan at gmail.com
Sun Jun 18 02:01:10 EDT 2006


On 2006-06-18 13:20:06, tylertacky write:
>Ok, I'm pretty new to python, so this might be a stupid question. I'm
>trying to write a simple text-based pong clone, and I can't figure out
>how to read key presses to move the paddles. I just need something that
>does the same thing as getch() and kbhit(). I can't use those because
>their windows only, and I'm running Linux.
>
>Someone suggested using curses, but that does crazy things with my
>output, and leaves the terminal unusable after the program closes.
>
>-- 
>http://mail.python.org/mailman/listinfo/python-list

The python.org site has a faq about getting keystroke. 
It uses termios and fcntl modules.
Here's the link:
http://www.python.org/doc/faq/library/#how-do-i-get-a-single-keypress-at-a-time

Hope it can help you! 
-----
Fan Zhang




More information about the Python-list mailing list