Devarshi
Devarshi

Reputation: 16758

Disable keyboard shortcut

I want to disable keyboard shortcut Command+Shift+4 when my Mac OS X application runs. Can anyone tell me how to do it?

Upvotes: 2

Views: 1700

Answers (1)

Gonzo Oin
Gonzo Oin

Reputation: 379

You can disable the system keyboard shortcuts with:

#import <Carbon/Carbon.h>

void *oldHotKeyMode = PushSymbolicHotKeyMode(kHIHotKeyModeAllDisabled); 

Make sure that you re-enable them with:

PopSymbolicHotKeyMode(oldHotKeyMode); 

Be careful if you do this, it makes it more difficult to switch away from your app with Cmd+Tab if it is misbehaving so it can mean that if your app misbehaves the user has to power off the system instead of just force quitting your app.

Tested and working with Mac OS X Lion.

Upvotes: 3

Related Questions