Comments:" Remapping Keys on Mac OS X Mountain Lion | Matthew Palmer"
URL:http://palmer.im/2013/01/remap-keys-os-x-mountain-lion/
Yesterday, overcome by an unfortunate desire to waste time, I decided I wanted to remap some of my keyboard keys to other things. Initially, I wanted to remap the Caps Lock
key to Command+R
for two reasons:
- I'm always hitting
Command+R
for building and running iOS apps and to refresh web pages Caps Lock
is otherwise entirely useless
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.
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.
In KeyRemap4MacBook click 'Misc & Uninstall' in the top tab bar. Click 'Open private.xml' to open it in Finder. Open the private.xml file in TextEdit. 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. The basic syntax for adding a new remapping is this: Replace KEYTOSTART 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.) As an example, here is what I used to remap Caps Lock (i.e. PC_APPLICATION) to Command+R: Save the private.xml file. Go back to KeyRemap4MacBook and hit 'ReloadXML' and your newly defined remaps should appear at the top of the list. Select the one you want. Try it out. Look through this page for more comprehensive documentation of what you can achieve. 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: