Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Modify Cocoa apps shortcut keys per user Apps
I snapped this tip up on Apple's mailing list: projectbuilder-users@lists.apple.com. 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 Mail.app to be command+shift+A:
defaults write com.apple.Mail NSUserKeyEquivalents '{"Activity Viewer"="@$A";}'
The odd characters before the 'A' in the previous command, specify the modifiers:
  • @ = Command
  • $ = Shift
  • ~ = Option
  • ^ = Control
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.
    •    
  • Currently 2.57 / 5
  You rated: 2 / 5 (7 votes cast)
 
[15,490 views]  

Modify Cocoa apps shortcut keys per user | 4 comments | Create New Account
Click here to return to the 'Modify Cocoa apps shortcut keys per user' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
System shortcuts
Authored by: Anonymous on Apr 16, '01 11:01:57AM

Would that also apply to SYSTEM SHORTCUTS such as:

• Hide Others
• Bring All To Front

If so, how can I assign them a shortcut?

Chad



[ Reply to This | # ]
For function keys?
Authored by: tlr on Apr 27, '01 02:06:42PM

This works well, but does anyone know how to handle the function keys? They are not described in Apple doc.



[ Reply to This | # ]
Function keys trick
Authored by: greg418 on Feb 11, '04 05:47:33AM
Setting shortcuts is now easier-than-ever in Panther, using the "Keyboard & Mouse" System Preferences panel. You can setup all the shortcuts you want in there, specifying for which app (all apps or a specific one), the menu item's name, and the wanted shortcut. Function keys are fully supported.

Anyway, if this is still of some interest to anyone, the Unicode character that represents the 'F1' key is f704 (... so @Uf704 as per the example). 'F2' is 'f705', etc.

To find out, I set "Quit Safari" in the Keyboard... panel to the F1 key and then ran "defaults read com.apple.Safari NSUserKeyEquivalents" in the terminal.

Cheers

Greg

---
loops of fury

[ Reply to This | # ]

Modify Cocoa apps shortcut keys
Authored by: ad7am on Oct 24, '08 11:48:29AM

Anyone know if this still works in Leopard? Thanks...



[ Reply to This | # ]