Monday, November 25, 2024

macos – How do I add, change or remove a key command (shortcut) from a menu item?

You can add a custom key command to almost anything that has a menu item.
It doesn’t matter where the item is in the hierarchy, unless there are two items with the same name [which is rare.] You can add commands globally, to all apps which contain that menu item, or just specifically to a single app – whichever you prefer.

Always make sure you’re not using a duplicate command already used for another function, and don’t try to use this as a one-stop solution to ‘fix’ Mac shortcuts to any you were used to in Windows… that never ends well 😉

Illustrations all on Mojave. I will add variants for Ventura when I can get access for a day. Ventura is visually different, but the methods are the same.
Let’s use Export Bookmarks… from Safari as our basic example, as it doesn’t already have a key command.

enter image description here

In System Preference > Keyboard > Shortcuts > App Shortcuts, click the + button. If you already have an entry for Safari, if you select that prior to clicking + then it will pre-populate the menu for you. You then add your menu title, exactly as written, move to the last box & press your chosen shortcut. It will be added to the menu as soon as you click Add.

enter image description here

enter image description here

Note that some macOS versions demand you use an ellipsis … if the menu item has one, some do not. It’s always smarter to add one anyway. You can generate an ellipsis on an English keyboard using Opt ⌥ ; [opt/semicolon].
Note that an ellipsis is not the same as three stops/periods.

To replace any key command, use the above method & simply add your preferred new command, it will instantly be swapped for your new trigger.


You cannot actually remove a key command that exists by default, but you can replace it with a ‘garbage’ command you will never need for anything else.

In Safari I never use the Reading list, but used to action it accidentally. Not any more…

enter image description here

F19 only exists on extended keyboards, but adding all the modifiers plus any key is unlikely to generate any clashes, nor be hit accidentally.


Modifier keys
You can use any and all modifiers in any combination, Cmd ⌘ Opt ⌥ Ctrl ⌃ Shift ⇧ . You cannot use Shift alone, but you can use it in combination with any or all of the others.
macOS does not differentiate between left and right versions of these keys [there is no AltGr like in Windows.]


If you do have a menu item that appears twice in the menus, each with a different purpose, then you do have to direct your key command to the correct one, using this syntax
menu->submenu->item
This can actually happen in such as Mail, where your Mailbox names appear at the bottom of many different hierarchies, depending on function. In this case, you would use such as
Message->Move to->Inbox->AccountName


Can you add just one single letter as a trigger?
Yes…and no.
This one is tricky and has changed over the years. It also needs your trigger to be ignored when you are in text areas, which limits functionality somewhat.

If you have an extended keyboard, then the keys on your numpad can be used as single triggers. Using our Export Bookmarks… example – here it is with just the single character 1 from the numpad used as our trigger.

enter image description here

Numpad keys are different from those above qwerty. The Mac knows which is which & handles then as separate entities – however you cannot tell by looking at the menu or preferences which is which. You just have to know that’s what you set it to.

If you are on any macOS before Ventura, you can also add a single key command by entering it as
Fn letter/number
This will then just register as that single key. For instance, Fn A gives just A as here…

enter image description here

All things considered, though, I wouldn’t recommend using single keys as triggers – there’s just too much room for error.


For our odd exception – the Preview Signature that doesn’t have a menu name to action – let me refer you to user3439894‘s excellent answer on Preview – add Signature by key command. Find Menu name This is quite complex, and far too much to add here, but it does work very well.


Things you cannot add key commands to
Contextual menus – those on right click.
If there is no corresponding item in an actual menu, this cannot be done.

‘Smart’ menu items – those that do exist in the regular menu, but change depending on context. The only option for this would be to add the same command to every single possible variation of that menu’s wording. As sometimes that would include the file or item currently selected, consider this somewhere on a scale of ‘unlikely’ to ‘impossible’, depending on complexity.


There are methods by which the experienced hacker can change menu items by manually modifying the associated .plist file for an app, but I consider that a bridge too far for this particular QA.
If you want to investigate for yourself, Safari’s .plist file is at ~/Library/Preferences/com.apple.Safari.plist. It only displays non-default key commands.

<dict>
    <key>Export Bookmarks…</key>
    <string>@~$e</string>
</dict>

If anyone finds any outliers, odd cases, or things that appear to plain ‘not work as intended’, please post a new question & link back to this one for reference.

Related Articles

Latest Articles