Shift-Control-Option-Command on Caps Lock

I’m not sure where I first saw a link to this detailed keyboard post by Steve Losh. The usual suspects would be Brett Terpstra, Gabe Weatherhead, and Clark Goble, but I’m thankful to whoever it was. Losh’s post has given me a great new tool for making keyboard shortcuts easier.

The central conceit of Losh’s post is to recreate the experience of the legendary Space Cadet keyboard on a Macintosh using today’s hardware and software. The Space Cadet came with the old Symbolics Lisp machines of the 80s and is renowned for its row of four modifier keys—Control, Meta, Super, and Hyper—that allowed users and programmers to define an enormous number of keyboard shortcuts. I’m not a big fan of doing everything from the keyboard, but there was one section of the post that I thought would give my keyboard use a big boost.

The problem in defining new keyboard shortcuts is that you want to make them relatively easy to type while not conflicting with shortcuts already defined. I tend to use Control-Option-Command combinations because

  1. Applications shy away from three-modifier combos, which leaves them free.
  2. Despite it being three keys, that combination is actually easy to type because the keys are all in a row. I just mash down on them with the ring, middle, and index fingers of my left hand—no fine motor control necessary.

But after using up the Control-Option-Command combinations that have an easy mnemonic association with their function, it becomes harder to add new functions. An obvious extension would be to start using Shift-Control-Option-Command, but that’s hard to type. Which is where Losh’s software recommendations come in.

The two applications—System Preferences, actually—Losh discusses are PCKeyboardHack and KeyRemap4MacBook, both of which are free programs written by Takayama Fumihiko. A simple variation on Losh’s instructions allowed me to remap the Caps Lock key on my MacBook Air to the Shift-Control-Option-Command combination. Now I can add more keyboard shortcuts without sacrificing ease of typing.

First, I followed Fumihiko’s instructions for installing both of his programs. Then I opened the builtin Keyboard System Preference and set the Caps Lock Key to No Action.

Keyboard System Preference

Then I opened the PCKeyboardHack Setting pane and remapped the Caps Lock key to keycode 80, which corresponds to F19 on keyboards that have an F19. Function keys on my MacBook Air max out at F12, so mapping Caps Lock to F19 causes no conflict.

PCKeyboardHack setting for Caps Lock

Next I opened KeyRemap4MacBook (which, despite its name, isn’t restricted to MacBooks) and opened its private.xml document from the Misc & Uninstall pane.

KeyRemap4MacBook private.xml

I set the contents of my private.xml to this,

 1:  <?xml version="1.0"?>
 2:  <root>
 3:  <item>
 4:      <name>Remap Caps Lock to Hyper</name>
 5:      <appendix>OS X doesn't have a Hyper. This maps Left Control to Control + Shift + Option + Command.</appendix>
 7:      <identifier>caps_lock_to_hyper</identifier>
 9:      <autogen>
10:          --KeyToKey--
11:          KeyCode::F19,
13:          KeyCode::COMMAND_L,
14:          ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L
15:      </autogen>
16:  </item>
17:  </root>

which is a minor rewrite of Losh’s private.xml. After saving and closing this file, I switched to KeyRemap4MacBook’s Change Key pane and activated the new entry.

KeyRemap4MacBook Change Key pane

It’s true that this remapping loses me the Caps Lock function, but I see that as a small price to pay for an entire alphabet’s worth of new keyboard shortcuts. Look out, FastScripts and BBEdit!

6 Responses to “Shift-Control-Option-Command on Caps Lock”

  1. Lauri Ranta says:

    I’ve used the same technique to add modifier keys for opening applications and commonly used files.

    I also have a custom keyboard layout that has a modifier key for inserting special characters under the right thumb. I tried assigning it to different combinations of normal modifier keys at first, but some key combinations like ⌘? or ⌃< were always impossible to press. Then I figured out I could use caps lock as the modifier key in the keylayout file:

    <keyMapSelect mapIndex="2">
            <modifier keys="caps"/>
        <keyMap index="2">
            <key code="0" output="="/>
            <key code="1" output="_"/>
            <key code="2" output=";"/>

    And add this to private.xml:

    <autogen>--KeyToKey-- KeyCode::N, Option::KEYTOKEY_BEFORE_KEYDOWN, KeyCode::CAPSLOCK, Option::KEYTOKEY_AFTER_KEYUP, KeyCode::CAPSLOCK</autogen>

    The LED can be disabled by checking Pass-Through CapsLock LED status.

  2. Carl says:

    The Google Chrome OS notebooks are pretty goofy in many regards, but they did one thing right: they ditch the otherwise useless CAPSLOCK key.

    On my computer, I have caps lock set to switch input methods to Japanese, but just about any function would be more useful than entering ALL SHOUTING MODE.

    The historical struggles between QWERTY and Dvorak aside, I think there’s still a fair amount of rethinking to be done on the keyboard. Why do we still only have straight quotes and backtick on the keyboard? Shouldn’t we have the curly quotes lined up logically like the various kinds of brackets? Why not have dedicated em-dash and en-dash keys in addition to regular dash? The Roman-alphabet mode of Japanese keyboards has @ as a plain key that can be activated without using shift. Isn’t that more suited to today’s email and Twitter filled world?

    On the other hand, at least Mac keyboards aren’t as totally worthless as PC keyboards. Numlock, seriously? The PC on my desk at work boots up with numlocks turned off for some unfathomably idiotic reason, and so far as I can tell, there’s no way to change this setting to something sensible.

    OK, I guess this has been a fairly rambling comment, but we use the keyboard all day everyday, so why not think a little about it? :-)

  3. Ben Brooks says:

    Great trick, but it looks like it doesn’t play nice with Keyboard Maestro. Meaning Keyboard Maestro doesn’t see the remapped key as the modifier keys.


  4. Dr. Drang says:

    That’s odd. It was my impression that the remappings from PCKeyboardHack and KeyRemap4MacBook act at a lower level than Keyboard Maestro. It’s worked fine with FastScripts.

    When you say KM “doesn’t see” the remapped key, are you talking about when the macro is defined or when it’s run? If it’s the former, you might get around the problem by defining your macro using the real modifier keys and then run it using the remapped Caps Lock.

  5. auto says:

    Thanks for this post.

    Minor typo/inconsistency issue: Your is “Remap Caps Locks”, but it should be “Remap F19”. Yes it’s your private.xml, but to be consistent, keyremap technically doesn’t know about what you do in PCKeyboardHack. Second, under , “Left Control” should changed.

  6. Dr. Drang says:

    auto is right. The description in the <appendix> item in private.xml is a leftover from Steve Losh’s original that I should have edited to make it consistent with what I’m actually doing.

    As for whether the <name> should be changed to “Remap F19 to Hyper,” I’m less certain. Unquestionably, that is what private.xml is doing—it’s PCKeyboardHack that’s remapping Caps Lock to F19. But since the overall purpose is to go from Caps Lock to Hyper, I thought that was a name that would be more meaningful to me.