20100828

10.4: Remapping keys in Mac OS X 10.4

10.4: Remapping keys in Mac OS X 10.4 

10.4: Remapping keys in Mac OS X 10.4 System 10.4
The Mac OS X 10.4 Keyboard & Mouse preference pane provides a way to remap certain keys. However, the interface doesn't expose the full functionality -- a common problem with Apple software. Note that this guide assumes you'using the bash shell.

Read on to learn...
  • What keys can be remapped without the use of any third–party software?
  • How do I remap those keys?
  • How do I remap the Caps Lock key to the Escape key?


What keys can be remapped without the use of any third–party software? (The following list shows the key name on the left, and that key's value on the right.)
  • None — –1
  • Caps Lock — 0
  • Shift (Left) — 1
  • Control (Left) — 2
  • Option (Left) — 3
  • Command (Left) — 4
  • Keypad 0 — 5
  • Help — 6
  • Shift (Right) — 9
  • Control (Right) — 10
  • Option (Right) — 11
  • Command (Right) — 12
  • Kernel Panic — 16
Be warned that the code 16, when used as the destination of a mapping, actually causes a kernel panic on keypress -- as I've found out the hard way.

How do I remap those keys?
  1. Remap one of the keys available in the Keyboard & Mouse preference pane in order to make the following steps easier.
  2. Locate the hidden property list file used to store the settings. It's in your user's Library/Preferences/ByHost folder, and is named.GlobalPreferences.000d*. I assume there'll be only one such file; you'll need to verify that. From here on, that file and path are referred to as$FILE.
  3. Duplicate the file and convert it to the XML property list format:
    $ cp $FILE ~/keys-binary.plist
    $ plutil -convert xml1 -o ~/keys-xml.plist ~/keys-binary.plist
  4. Open the resulting XML file and locate thecom.apple.keyboard.modifiermapping key. Its value is an array containing several entries, each in turn containingHIDKeyboardModifierMappingSrc and HIDKeyboardModifierMappingDstkeys. The values of those keys are described in the table above. Make the changes you wish to make, and save your work.
  5. Convert the file back to the binary property list format, and put it back in the correct location:
    $ plutil -convert binary1 -o ~/keys-binary.plist ~/keys-xml.plist
    $ cp ~/keys-binary.plist $FILE
  6. Log out and back in to apply changes.
How do I remap the Caps Lock key to the Escape key?

Unfortunately, this will require the use of a third–party program. I used a free trial version of Keyboard Maestro by Stairways Software. First, remap the Caps Lock key to the Help key, following the instructions above. Then, in Keyboard Maestro:
  • Create a new macro.
  • Add a Simulate Keypress action, with an User Keystroke — the Escape key.
  • Add a Hot Key trigger, set to the Help key.
  • In the Preferences section, enable the Launch Engine at Login option. While you're at it, you might also want to disable all other unnecessary features.
An always up–to–date version of this guide can be found on my blog...

No comments:

Post a Comment