[Tutor] How to Capture a key being pressed?
Alan Gauld
alan.gauld at btinternet.com
Wed Jan 4 20:05:28 CET 2012
On 04/01/12 18:28, brandon w wrote:
> How do I capture a key like the <Space> bar or the <Enter> key?
It depends on your OS.
For Windows use msvcrt and the getch() function.
For other OS your best bet is curses.
See the "Event Handling" topic in my tutorial for examples
using both.
There is a terminal module that tries to hide the differences.
There is also a 3rd party module tat offers more functionality on Windows.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list