Catching keystrokes under Windows

Olli Piepponen ote at mbnet.fi
Wed Nov 19 12:51:40 EST 2003


Hi,

I'm having a little problem catching keystrokes under Windows. I did a 
little research and found that with mscvrt.getch() one can cath a single 
key that is pressed. However this doesn't work when the program is run 
on the backround and not as the primary task. What I would like to have 
is a same sort of function that would also work when the program is being 
run on the background. I'm trying to implement a program that would listen 
for a certain key to be pressed and then start a timer that would *beep* 
after 30 seconds or so. I've everything else sorted out except how to 
catch the one key. 

So is there an easy way like msvcrt.getch() is or does one have to start 
playing with the win32api module? If the win32api-module is needed for this 
task could you also explain how? Python is my first real programming 
language so I don't understand too much about C\C++ stuff. Examples would 
be highly appreciated.




More information about the Python-list mailing list