A few months ago, Steve Losh posted on his keyboard setup. His setup is very
intimidating impressive, but unfortunately his post was mostly of the ‘what I do’ variety, with Steve commenting that:
I’m not going to give you a tutorial here — read the documentation if you want to learn how to use the things I’m going to show.
This post reflects my efforts to fill in those gaps… I use it for vim, but you could use this setup for any number of things.
Now we want to open the ‘Modifier Keys’ tab — the modifier keys are command, option (alt), control and caps lock (because they modify what other keys do).
Set the caps lock key to control (I know, you want it to map to escape, but trust me, this is even better).
Now, install KeyRemap4MacBook. It is important you pay attention to step two in the installation instructions:
Control-click or right click the pkg file, then select “Open” from the top of contextual menu that appears. Important You must open the pkg file from contextual menu in order to pass through Gatekeeper
Once you are installed and have reset, you are ready for some mapping magic: you can map escape to caps lock, and much more!
Go back to system preferences (under the apple logo top left), and now you’ll notice a new logo in the bottom left, under the ‘Other’ heading — click on that to open our (new) keyboard remapping tool.
This next step is Steve’s great insight — we really only need to tap the escape key. So what we are going to do is to map it such that a short tap on the caps lock key sends the escape signal, and a longer hold down sends control. When we have done this, we will have two of the most useful keys on the keyboard in pretty much the best spot.
To do this, we must change Control_L (Left Control) – so expand that tab.
Scroll down, and find the option that is (confusingly) titled ‘Control_L to Control_L (+ When you type Control_L only, send Escape)’ — select that. Now the biggest problem with this is that one man’s tap is another man’s hold. The computer decides which based on how long you hold it down.
To modify this behaviour, we must open the Key Repeat tab (see the above picture — it’s highlighted at the top).
Once in the key repeat tab, tweak the ‘[Key Overlaid Modifier] Timeout’ option. I lowered mine to 300ms, and haven’t had any problems with getting an Escape when I expected a Control.
I wanted my caps lock key back, so I mapped escape to caps lock. Back into System preferences / KeyRemap4MacBook, and this time select the ‘Change Escape Key Option’.
The first option is to map the Escape key to CapsLock. Check that option and you’re in business.
This last part is a how-to for an advanced trick that Steve employs. With the caps lock key now sending a Control message when held down for more than 300ms, the existing left control key is redundant.
So … Steve maps it so Command-Option-Control-Shift — a combination that he calls ‘Hyper’.
Why bother? If you use Safari, you’ll find that using it in combination with the left and right arrow keys will change tabs, which I think it pretty useful. Another good reason to do it is that it gives you some exposure to creating custom mappings.
First of all, you’ll need to download PCKeyboardHack. It’s from the same folks as KeyRemap4MacBook, and once again you must control-open it and restart after the install.
With that done, you can open the programme.
You may have to scroll in the menu below, to find the key code for — note the code is 80. We are going to remap the left control key to send key code 80 (so that your system thinks it’s getting the F19 code).
Next, expand the ‘other keys’ tab:
Select ‘Change Control_L’, and enter 80 into the keycode box.
Now your system will get an F19 message — if you have a normal keyboard setup, it won’t do anything. So … back to KeyRemap4MacBook to intercept that F19 message, and substitute our ludicrous mapping.
This time we go to the ‘Misc and Uninstall’ tab, and hit the ‘open private.xml’ button. There is a guide to editing these things, but you should get the idea from how we make the ‘ludicrous’ key.
<?xml version="1.0"?> <root> <item> >name>Remap Left Control to Hyper</name> <appendix>Maps left control to control + shift + option + command</appendix> <identifier>space_cadet.left_control_to_hyper</identifier> <autogen> --KeyToKey-- KeyCode::F19, KeyCode::COMMAND_L, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L </autogen> </item> </root>
So open your private.xml, and add the above (just copy and paste).
Now you have that added, go back to the ‘Change Key’ tab, hit the ‘ReloadXML’ button, and you should have a new mapping option. Select that, and you’ll have your new key.
An immediate benefit of this is that you can change tabs easily in Safari, and as Steve notes, it gives you pretty much an entire ‘namespace’ to map your own shortcut keys to (a task for which he employs Keyboard Maestro).