I have a user request (actually it’s more like a demand) that I trigger a program function using an Apple-reserved keyboard shortcut. The request is rooted in the fact that some very popular commercial applications use the shortcut in question to perform a similar action (specifically: command-space to zoom in on a view, which is reserved for bringing up the Spotlight search bar; my users claim this is implemented by Adobe Photoshop, InDesign, and several other tools to zoom in…I haven’t verified that claim).
I have tried a few experiments with Xojo under Mavericks and it doesn’t even seem possible to override command-space (even after going into the Spotlight control panel and un-ticking the checkbox for keyboard shortcut). This may be good news, as it takes me off the hook but I thought I’d ask here in case others have any experience with this.
You could add a menu item to the menubar with the key that activates it a single space and the menu modifier set to on. This will give you a command space menu that could be handled by your application and call the appropriate function. Of course this will only work if your user is willing to disable the spotlight shortcut since the OS seems to catch the combination before it reaches the app. As for Photoshop zooming in with command space I’ve never seen it and when I press command space in Photoshop Spotlight comes up as expected, but I suppose it’s possible it is some hidden feature I have never seen before.
My users are definitely not idiots, though they can be pretty conservative about changes to UI. This link seems to verify the claim for Photoshop, though I don’t know how old this or if it’s current for Mavericks, but it apparently worked at one time in Photoshop’s history: http://digital-photography-school.com/8-secrets-of-the-zoom-tool-in-photoshop (see #2, "Zoom while you work). I will have them double-check on the other apps but I really don’t have any reason to doubt them.
As to the MenuItem approach and disabling Spotlight’s key commands: that’s the first thing I tried. Also tried intercepting KeyUp/KeyDown with Keyboard.AsyncCommandKey, etc… It seems like command-space bypasses my app altogether and goes directly to the OS (again, this is in Mavericks…not sure of older OS X but that’s somewhat moot now).
Command-Space was zoom in the Adobe applications for many years before Apple assigned it to the Spotlight menu item, and Adobe users have been disabling this key command ever since in favor of its original use. I say go for it. In all my years of user support, I don’t think I’ve ever seen a single person use Command-Space to intentionally use Spotlight. I’ve seen many, many unintentional events, though.
Indeed, this apparently goes way back, pre-OS X (and 9, and 8), and is in Photoshop, Illustrator and several other apps (a search for “Adobe command space zoom” yields quite a few hits).
Disabling it there is the same as disabling it in the Spotlight menu.
I’d previously mentioned that doing that “didn’t work”, and that was true for me, but I’d neglected to mention or even register in my own brain that I’m using an external, third-party keyboard and it doesn’t work with that. But it does in fact work with the native keyboard, as long as the Spotlight shortcuts are disabled.
So I think I will implement it as requested, but will have to leave it to the users to turn off the Spotlight shortcuts (unless there’s some way I can do that programatically…? Probably fodder for a separate thread…).