I use Hammerspoon for window management in OS X. It's lovely being able to drive specific operations with the keyboard, but what's not lovely is trying to find a spare keyboard shortcut that doesn't need lots of fingers and doesn't clash with another app.
Taking inspiration from this article and the article it took inspiration from, I've taken to mapping Caps Lock to Shift+Ctrl+Option+Command, which is such a crazy set of modifiers that no app would ever have a default keyboard shortcut based on it. That means I get a single key which acts like all four normal modifier keys combined, so I get a whole blank keyboard of shortcuts all to myself!
The specifics of how I did this:
- Open System Preferences, then Keyboard, then Modifier Keys
- For each keyboard listed, set Caps Lock to No Action
- Install Karabiner and Seil, then restart your Mac
- Launch Seil
- Tick Change Caps Lock and set the keycode it sends, to 80 (which is really F19. If you have a keyboard which has a real F19 key, you need to change this to a different key you don't have)
- Launch Karabiner
- Choose the Misc & Uninstall tab and click Open private.xml. This will give you a Finder window with a private.xml visible
- Right click private.xml and choose Open With then TextEdit.app
- Paste the following between the <root> and </root> tags:
<name>Remap F19 to Hyper</name>
<appendix>OS X doesn't have a Hyper. This maps F19 to Control + Shift + Option + Command.</appendix>
ModifierFlag::OPTION_R | ModifierFlag::SHIFT_R | ModifierFlag::CONTROL_R
- Save and Quit the private.xml window, close the Finder window
- Back in Karabiner, switch to the Change Key tab and click ReloadXML
- You should now see Remap F19 to Hyper at the top of the list. Tick it.
- At this point you should be done, but we can easily test to make sure...
- Switch to the Misc & Uninstall tab in the Karabiner preferences and Launch EventViewer
- Press your Caps Lock key and you should see a series of events appear, each of which adds/removes one of the Shift/Ctrl/Option/Command keys. The middle row should have Shift Ctrl Opt Cmd in the flags column. If you see that, you are done!
- Configure lots of shiny new Hyper shortcuts in Hammerspoon or whatever other app you like!