[Tutor] Get keyboard input while other program is in focus?

billburns at pennswoods.net billburns at pennswoods.net
Mon Oct 16 19:03:38 CEST 2006

> > What commands can I use to have the program know a certain key has
> > been pressed while another program is in focus?

> I think Pygame and TKInter have a capture-all-keys function, but this
> might also prevent the keypresses from actually going to the target
> application.

If you need this to work on Windows - take a look at pyHook:


As Luke has stated... it's possible to stop the key presses from reaching their
target application. If you do use pyHook, make sure your functions always return
True (this allows the key press to hit it's destination).



More information about the Tutor mailing list