Assign one keyboard shortcut to multiple menu items

Feb 29, '08 07:30:05AM

Contributed by: robg

You may have read the title to this hint and thought "Huh? How can that possibly work? How does the system know which command to run when you type the shortcut? And why would you want to do this?" A bit more explanation is required to see the benefit of this hint: it's for use with menu items whose names change after they've been selected.

In this case, I wanted an easier way to toggle the display of smileys off and on in iChat (because iChat replaces =$ with a "dollar sign smiley face," meaning that pasted code often looks quite odd). Disabling smileys is done with View » Messages » Hide Smileys. Easy enough to assign that to Control-S, for example, in the Keyboard Shortcuts tab of the Keyboard & Mouse System Preferences panel. But once you've hidden smileys, that menu item becomes Show Smileys, and the keyboard shortcut vanishes. On a lark, I tried assigning Show Smileys the same Control-S shortcut...

I was fully expecting OS X to tell me that I couldn't assign Control-S again, as it had already been assigned to another function in iChat. But no such error message appeared, as you can see in the image above. This works perfectly -- Control-S toggles smileys both off and then back on again.

This should work in any application that has menu items whose names change based on the status of the feature they control. However, I've only tested it in iChat -- and only on 10.5, so I'm not sure if this works in 10.4, too.

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080229063434499