Fake Hyper key for OSX

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:

  1. Open System Preferences, then Keyboard, then Modifier Keys
  2. For each keyboard listed, set Caps Lock to No Action
  3. Install Karabiner and Seil, then restart your Mac
  4. Launch Seil
  5. 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)
  6. Launch Karabiner
  7. Choose the Misc & Uninstall tab and click Open private.xml. This will give you a Finder window with a private.xml visible
  8. Right click private.xml and choose Open With then TextEdit.app
  9. 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
  10. Save and Quit the private.xml window, close the Finder window
  11. Back in Karabiner, switch to the Change Key tab and click ReloadXML
  12. You should now see Remap F19 to Hyper at the top of the list. Tick it.
  13. At this point you should be done, but we can easily test to make sure...
  14. Switch to the Misc & Uninstall tab in the Karabiner preferences and Launch EventViewer
  15. 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!
  16. Configure lots of shiny new Hyper shortcuts in Hammerspoon or whatever other app you like!


Leave a response