MacOS – How to set a keyboard shortcut that includes the backspace key

keyboardmacos

My question is in the title: does OS X allow to set a shortcut with backspace, like Ctrl+Option ⌥+Command ⌘+backspace (in my case to an Automator service)?

Edit:
You might think "Try it yourself"; well, I did it. In System Preferences → Keyboard → Shortcuts, I tried to add this shortcut to my service and it doesn't work. The problem seems to be with backspace. Ctrl+Option ⌥+Command ⌘+m works well.

Does anybody know a workaround that allows me to use the backspace key in a keyboard shortcut?

Best Answer

To change the shortcut of a service, run plutil -convert xml1 ~/Library/Preferences/pbs.plist, open the plist, and change for example

<key>(null) - Some Service - runWorkflowAsService</key>
<dict>
    <key>key_equivalent</key>
    <string>@~a</string>
</dict>

to

<key>(null) - Some Service - runWorkflowAsService</key>
<dict>
    <key>key_equivalent</key>
    <string>@~&#x8;</string>
</dict>

Then restart to apply the changes.

@ is command, ~ is option, and &#x8; is delete (Windows backspace). Forward delete (Windows delete) would be &#x7f;. The shortcut strings use the same format as in DefaultKeyBinding.dict.

To change a global shortcut set in the App Shortcuts section, run plutil -convert xml1 ~/Library/Preferences/.GlobalPreferences.plist, open the plist, and change for example

<key>Some Menu Name</key>
<string>~@a</string>

to

<key>Some Menu Name</key>
<string>~@&#x8;</string>

Then quit and reopen applications to apply the changes.

Application-specific shortcuts are stored in ~/Library/Preferences/*.plist and ~/Library/Containers/*/Data/Library/Preferences/*.plist.