How to create a global hotkey?

Diez B. Roggisch deets at nospam.web.de
Thu Dec 7 07:07:55 EST 2006


k04jg02 at gmail.com wrote:

> I want to make a Python app that runs in the background, and when a
> user hits a key combination, for a function to run. This sounds simple
> enough, but all of the keypress detecting libraries I can find count on
> you creating a window and then detecting keypresses while that window
> has focus. I want my function to execute when the user presses the
> hotkey anywhere. I searched the PyGTK documentation and found an old
> newsgroup post where someone mentioned the C GTK+ library has it but
> PyGTK does not, PyQT showed no results, not sure where else I should
> look. I'd be willing to use a library that isn't a windowing toolkit --
> I just want to be able to be able to globally detect a keypress. Any
> ideas?

What OS on? That is the key question here (sorry for the bad pun). It
heavily depends on that, and possibly it hasn't to do with python at all,
but instead configuring e.g. your window manager.

Diez



More information about the Python-list mailing list