Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

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 the com.apple.keyboard.modifiermapping key. Its value is an array containing several entries, each in turn containing HIDKeyboardModifierMappingSrc and HIDKeyboardModifierMappingDst keys. 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...
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[46,526 views]  

10.4: Remapping keys in Mac OS X 10.4 | 17 comments | Create New Account
Click here to return to the '10.4: Remapping keys in Mac OS X 10.4' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Or else use DoubleCommand...
Authored by: murali1080 on Tue, Aug 29 2006 at 8:43AM PDT
Die Enter, die!
Authored by: atverd on Tue, Aug 29 2006 at 9:55AM PDT
Finally I can reassign that dreadful Enter key on my MBP to nice and useful Option key! Thank you!

[ Reply to This | # ]
Or else use DoubleCommand...
Authored by: mietek on Tue, Aug 29 2006 at 7:29PM PDT
Tell me, how exactly am I supposed to remap the Caps Lock key to the Escape key using DoubleCommand? :P

[ Reply to This | # ]
Or else use DoubleCommand...
Authored by: lynxman on Wed, Aug 30 2006 at 2:56AM PDT
Be warned that DoubleCommand issues a kernel panic on boot with the lastest Mac OS X 10.4.7 on Intel machines, at least on my two laptops
I found the utility to be extremely useful until I found myself without the capability of booting my Macbook :(

[ Reply to This | # ]
Or else use DoubleCommand...
Authored by: cp420 on Thu, Aug 31 2006 at 8:19AM PDT
I had the same exact problem...

[ Reply to This | # ]
kernel panic
Authored by: gregpare on Tue, Aug 29 2006 at 9:14AM PDT
"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. "

Awesome.

I'm sure that it drove you nuts, but it was fun to read...

[ Reply to This | # ]
kernel panic
Authored by: mietek on Tue, Aug 29 2006 at 7:24PM PDT
I'm glad to hear it. :)

[ Reply to This | # ]
10.4: Remapping keys in Mac OS X 10.4
Authored by: sd on Tue, Aug 29 2006 at 9:30AM PDT
of course, the use of Apple's Plist Editor (I think every MOXH.com reader should know it, othervise it comes with developer tools) will spare you time about the conversion and Terminal stuff!

[ Reply to This | # ]
Remapping "Multimedia" keys?
Authored by: kkL on Tue, Aug 29 2006 at 10:57AM PDT
BTW: Does anyone know is it possible to remap multimedia keys?
(extra buttons that are ment to control Explorer/Media Player/Clipboard on Windows)

These seem to be very different than usual keys (Ukelele keyboard remapper doesn't see them pressed)

[ Reply to This | # ]
10.4: Remapping keys in Mac OS X 10.4
Authored by: S Barman on Tue, Aug 29 2006 at 3:41PM PDT
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.
Hmm... do I smell a future April Fool's Trick?? ;-)

[ Reply to This | # ]
10.4: Remapping keys in Mac OS X 10.4
Authored by: jacobolus on Tue, Aug 29 2006 at 6:37PM PDT
This is an absolutely horrible april fools joke. A good joke doesn't crash a system, it pranks it. Search for "cocoa text system" for a hint with lots of pranking capabilities. Remapping the shift button to number pad 0 or something might be pretty good. But a kernel panic button… that's just cruel, in the worst way.

[ Reply to This | # ]
10.4: Remapping keys in Mac OS X 10.4
Authored by: osxpounder on Wed, Aug 30 2006 at 1:49PM PDT
I feel the same way. A good prank can be undone by the victim, but this kernel-panic inducer would be too cruel because it'd be so hard to troubleshoot. Analogy: it's ok to saran-wrap a coworker's cube, because she can unwrap it, but not ok to spray-paint her cube or fill it with concrete.

A good prank idea: Back in oS9 days, I snuck a pair of Applescripts onto a coworker's machine. One of them set the Date and Time options to announce the time [every 15 min. I think]. The other script detected when the first script was deleted, and restored it immediately. It took her a few hours, not that she tried that hard, but she eventually found 'em both. Now that's a prank, and I would only have done it to her or one other person, the only 2 users I knew who were savvy enough to know where to look for the prank's parts.

[ Reply to This | # ]
10.4: Remapping keys in Mac OS X 10.4
Authored by: Ripcord on Wed, Jan 24 2007 at 6:45AM PST
Incidentally, the latest DoubleCommand (at the link above) works perfectly for me on a Macbook Pro + 10.4.8.

[ Reply to This | # ]
s/keyboard.maestro/quicksilver/
Authored by: ra5ul on Fri, May 9 2008 at 10:04PM PDT
why am i just now learning about this hint?

caps lock = esc
1. remap caps lock to help
2. quicksilver trigger this script:
tell app "System Events" to key code 53
3. set "hot key = help" and "activate = on release"

[ Reply to This | # ]
10.4: Remapping keys in Mac OS X 10.4
Authored by: iloatheny on Tue, Aug 19 2008 at 4:51AM PDT
Is there a way to make arbitrary keys behave as modifier keys? I'm left-handed and my setup doesn't really allow me to have a full-size external keyboard, so I'd like to buy a USB numeric keypad and assign the frequently used modifier keys (cmd, opt, ctrl, fn and shift) to the keys on the keypad.

I looked into DoubleCommand and fKeys and Keyboard Maestro, none of which fit the bill. Perhaps there's a clever hack that strings multiple things together for a solution?

Anyone?

[ Reply to This | # ]
10.4: Remapping keys in Mac OS X 10.4
Authored by: ihadmeavision on Mon, Jul 13 2009 at 1:56PM PDT
I really need this, so sorry for opening an old post. Anyone have any instruction updates for 10.5.7 in simple easy to understand steps? I'm a terminal newbie but have Apple's Property List editor if that helps. The .global files (I have several) referred to in this hint show no signs of having a "com.apple.keyboard.modifiermapping key" entry on my system.

I just want to make my right option key act as the enter key which they removed from the newer laptops. Any help is really appreciated, Thanks.

[ Reply to This | # ]
Remapping keys in Mac OS X
Authored by: jammi on Tue, Sep 15 2009 at 7:59PM PDT
Still works in Snow Leopard. If you are unsure about which plist to edit, you can change the setting in the Keyboard preference panel. This will update the plist file so you can just select the most recent one. Also notice that there are now arrays for each keyboard your Mac has been used with. To be sure, make the changes to each of them. In my scenario, I wanted a separate meta key for Terminal (I want the symbols option and shift-option produces in addition to meta functionality). I have "always" had caps lock as a control key. To accomplist the meta key task, I first mapped the left ctrl key (has been useless before) mapped to "keypad 0" (code 5). Then I edited my custom keyboard layout (.keylayout) file with Ukelele:
  • I created a new dead key map for "keypad 0".
  • Then, for each key in the dead key map, I added  (ESC) plus the key itself
  • For instance, the dead key for "a" is configured as a (ESC + A)
This allows the ex-ctrl to be used as a better meta key, no Keyboard Maestro needed.

[ Reply to This | # ]