Working with events for processing global hotkeys on Mac OS X
<p><strong>What I want:</strong></p>

<p>I have a program running. When the program is in the tray and out of focus, I want to have a couple of global shortcuts set up to send messages to the program. What do I mean by "send messages"? Well, inside my program, all I want is to have an access to some flag, which would indicate the state the specified key-pair (fired or not). I would poll the flag in the loop and take a decision from there.</p>

<p><strong>What I found:</strong></p>

<p><a href="https://stackoverflow.com/questions/3760318/system-wide-hotkey-for-an-application">System-wide hotkey for an application</a></p>

<p><a href="https://stackoverflow.com/questions/11347862/system-wide-shortcut-for-mac-os-x/11348122#11348122">system wide shortcut for Mac OS X</a></p>

<p><strong>What I do not understand:</strong></p>

<p>From the links above it looks like I have to pass a handler when registering a hotkey. On a hotkey press, OS calls the handler. It that right? What I do not understand is how in the world the system would call a handler inside my program if my program is running.</p>