Advice: overriding OS-reserved keyboard shortcuts?

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’m well aware of Apple’s guidelines on this: https://developer.apple.com/library/mac/documentation/IDEs/Conceptual/xcode_help-command_shortcuts/SystemAndOther/SystemAndOther.html, specifically the warning, “Do not override these shortcuts” so you don’t need to scold me about that. I have relayed this back to those requesting the feature. However, since the other applications are apparently able to override, and since my users also make use of those applications daily, they prefer consistency over conformance to the guidelines and are making some noise about me implementing it the same way.

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 :slight_smile: 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.

[quote=67996:@Joshua Hadley]my users claim this is implemented by Adobe Photoshop, InDesign, and several other tools to zoom in…I haven’t verified that claim).

[/quote]

You better verify this claim. Looks terribly bogus : cmd-space triggers spotlight in Photoshop like anywhere else. Zoom in is triggered by cmd +. Sometimes customer is king … of idiots :wink:

Why not offer fn space or Ctrl-space instead ?

Thanks for the replies.

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).

I tried it with menu handlers before I posted earlier and it worked for me with 10.7.5. so it looks like it could be a Mavericks issue.

Have you tried disabling the shortcut in the Keyboard Preferences Pane? That works for me under Mavericks.

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.

I found a couple similar questions on StackOverflow and both were answered with “Event Taps” but they didn’t go into examples or code. Here’s the link if you can make sense of it…
https://developer.apple.com/library/mac/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html

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…).

Thanks, all for the replies!