Modifying application shortcuts
Or, how to spend two hours on your machine on a Sunday morning, when you could go take a walk instead...
Here I talk about an itch I felt the need to scratch this morning, and about 2 applications: CheatSheet, and customShortcuts, and I put a lot of references at the end, so have fun reading!
You can change shortcuts in System Preferences > Keyboard > Shortcuts > App Shortcuts
Most of the things you'll ever need to do can be done there.
But then, some can't.
This morning, I realized that in Mail.app, moving from Delete
(Cmd+Del
) to Mark as Read
(Shift+Cmd+U
) when I read and sort my mail, was not what I wanted.
When I read my mail, there are obvious deletes, but a lot of my casual mail can just be not read (discussion lists, where only a few threads are interesting), or specifically marked for later reference. But moving from Cmd+Del
to Shift+Cmd+U
involves a lot of friction and I want to get rid of that.
I want to have something like:
Cmd+Del
=Mark as Read
(orMark as Unread
, depending on context)Shift+Cmd+Del
=Delete
and since that one is taken by "Erase Deleted Items > In All Accounts...
", which I never use, I'd move that item toAlt+Shift+Cmd+Del
=Erase Deleted Items > In All Accounts...
That way, I have my morning "mail discussion parsing" workflow all centered on Del
, which is a Good Thing™.
The problem is that the System Preference panel has its ideas on what can and cannot be done, and won't allow us to assign Cmd+Del
to anything but Delete
...
I know there are solutions that give you access to key bindings data, things that are really interesting and let you dive into the intricacies of the OS, but I was not really in that mood this morning (I put all the references at the bottom, there is plenty to read and play with, when you have time).
I remembered that there was an app that gives you all the shortcuts available in any given app (at least apps that live into the macOS GUI system, i.e. basically anything that has a real macOS menu at the top of the window, including Java apps like OmegaT, Electron apps like TMXEditor, etc.), the app is "CheatSheet" and can be found here:
https://www.mediaatelier.com/CheatSheet/
Just out of renewed curiosity, I decided to take a peek, just in case...
And there, behold! There is a link to that companion app: "CustomShortcuts" that (also) "works hand in hand with CheatSheet" by allowing you to edit shortcuts directly in the CheatSheet interface, which is pretty neat...
https://www.houdah.com/customShortcuts/
After a quick download and a few authorizations, I can now do what I wanted to do (assign Cmd+Del
to Mark as Read
, etc.), plus customShortcuts has autocompletion of menu item names, so you don't have to actually check the target application interface and worry about whether "...
" is three dots, or an ellipsis… (← this thing).
Et voilà, I've got my workflow fixed now, I can spend the rest of my Sunday with my heart at ease, and here are the references I promised:
References
- This URL seems to be a good summary of what you ought to know about what macOS gives you easy access to:
https://www.howtogeek.com/209725/how-to-customize-your-os-x-keyboard-and-add-shortcuts/ - This thread on reddit gives further advice for more involved modifications, like Automator, etc.:
https://www.reddit.com/r/MacOS/comments/pfjae3/anyone_else_find_the_keybindings_lacking/ - I love Xahlee's work in general and have bought his emacs and emacs lisp reference because it is so useful. His work on Mac keyboards is just as interesting:
http://xahlee.info/kbd/Mac_OS_X_keymapping_keybinding_tools.html - ss64 is a site that I have known for a while, but that I mostly remembered for the keybindings reference it gives. The whole site is very interesting:
https://ss64.com/osx/syntax-keybindings.html
https://ss64.com/osx/syntax-keyboard.html - And there is this 2006 reference to customizing the Cocoa text system here, that "hard core reference" I mentioned above, that is also extremely interesting:
https://www.hcs.harvard.edu/~jrus/Site/Cocoa%20Text%20System.html - Last but not least, the two links below come from Apple's developer documentation:
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html
https://developer.apple.com/documentation/appkit/nsstandardkeybindingresponding?language=objc
Post scriptum
You may want to give CheatSheet a "longish" delay before appearing when you hit Cmd
, because it gets tiring real quick to have it pop up while you think about the shortcut you actually want to hit while holding Cmd
, which really happens all the time...
In 2009, I had put together a similar thing on how to play with keybindings in the shell. It is here:
Bash (command line) shortcuts