In a Cocoa application, I am trying to find a way to catch system events, such as an application switch, usually triggered by Cmd-Tab or spotlight, usually triggered by Cmd-Space. Iām looking for either a way to catch a key event, or any other way that tells me that one of these events should happen, and ideally cancel it.
Apple Screen Sharing for Remote Desktop does this, so it should be possible. It catches these events and sends them to the connected remote computer.
Here is what I have already tried:
- Search for events using the sendEvent method in NSApplication. I see all events, such as Cmd keydown, Key keydown, but when both are pressed, I see nothing.
- Register a Carbon hotkey listener. I can register something like Cmd + Q, but then again, when I register Cmd + Tab, it does not respond.
Any other ideas?
source share