Matthew Palmer

Remapping Keyboard Keys on Mac OS X Mavericks

This is an updated version of my original guide on how to remap keyboard keys on OS X.

Here's how to remap any of your keyboard keys to any combination of keys on Mac OS X. Initially, I wanted to remap the Caps Lock key to Command+R for two reasons:

Here are the steps and workarounds I used to get what I wanted. I've essentially remapped the Insert, Home, Page Up, Delete, End and Page Down, and Caps Lock keys into a useful macro block.

  1. Download the latest version of KeyRemap4MacBook; it's pretty much the only decent key remapper for Mac. Despite its horrible name, it is insanely flexible and powerful.
  2. Install KeyRemap4Macbook as per the instructions on their website.
  3. Download PCKeyboardHack if you want to remap the Caps Lock key.
  4. Open PCKeyboardHack (from the Launchpad), and under the Caps Lock section select Change Caps Lock.
  5. Change the keycode in the right hand column to '110'.
  6. Open KeyRemap4MacBook from ~/Applications.
  7. Scroll down to 'For PC Users', expand it, expand 'Change PC Application Key'.
  8. Select whatever key you want the Caps Lock key to remap to (I set it to 'Application Key to Command_L').

Not exactly perfect, right? There's a very limited selection of keys you can remap to. Don't worry, with a little .xml hacking we can get it to do what we want (in a way). For those of you who are happy to just use it like this, don't worry about the next bit. For this section, we are going to introduce user-defined key remapping.

  1. In KeyRemap4MacBook click 'Misc & Uninstall' in the top tab bar.
  2. Click 'Open private.xml' to open it in Finder.
  3. Open the private.xml file in TextEdit.
  4. Open this private.xml file in your browser. Copy and paste the code from this remote file to replace the contents of the local private.xml file.
  5. The basic syntax for adding a new remapping is this:

  6. Replace STARTKEY with some key from this list. Make sure you use the uppercase name in the left column to replace KEYTOSTART. (KeyCode:: must be left as it is.)

  7. As an example, here is what I used to remap Caps Lock (i.e. PC_APPLICATION) to Command+R:

  8. Save the private.xml file.

  9. Go back to KeyRemap4MacBook and hit 'ReloadXML' and your newly defined remaps should appear at the top of the list.

  10. Select the one you want.

  11. Try it out.

  12. Look through this page for more comprehensive documentation of what you can achieve.

  13. Keep defining new remaps until you've got exactly what you want.

So, eventually, we worked out a way to remap any key we want to another key or combination of keys. It works really well, and it's probably good for RSI or something. At the very least, our laziness has been satiated. If I've done something wrong or you have questions, feel free to contact me on Twitter.

For anyone interested, here is my full private.xml file:

I'd love to hear your favourite key remappings, feel free to share them with me on Twitter.

Subscribe via RSS