Modify Cocoa apps shortcut keys per user

Apr 15, '01 09:03:59AM

Contributed by: chmod007

I snapped this tip up on Apple's mailing list: Full credits to the author, Mike Ferris.

You can modify any keyboard shortcut in any Cocoa app using the very powerful defaults system. The key you want to modify in your defaults database is NSUserKeyEquivalents.

The following example would set the Activity Viewer menu item of to be command+shift+A:

defaults write NSUserKeyEquivalents '{"Activity Viewer"="@$A";}'
The odd characters before the 'A' in the previous command, specify the modifiers:To use other keys, such as Delete, you will have to use their Unicode codes like this:

@U0008 which would mean command+Delete.

This is really good, since it does not involve modifying the original application, and only applies to your environment, leaving that of others unchanged. I will try to make an app to handle this proceedure some time in the future.

Comments (4)

Mac OS X Hints