Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,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 3.57 / 5
  You rated: 5 / 5 (7 votes cast)
 
[101,558 views]  

10.4: Remapping keys in Mac OS X 10.4 | 19 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 whoever posted them. This site is not responsible for what they say.
Or else use DoubleCommand...
Authored by: murali1080 on Aug 29, '06 08:43:06AM
Die Enter, die!
Authored by: atverd on Aug 29, '06 09:55:17AM

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 Aug 29, '06 07:29:27PM

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 Aug 30, '06 02:56:20AM

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 Aug 31, '06 08:19:12AM
I had the same exact problem...

[ Reply to This | # ]
kernel panic
Authored by: gregpare on Aug 29, '06 09:14:05AM
"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 Aug 29, '06 07:24:51PM

I'm glad to hear it. :)



[ Reply to This | # ]
10.4: Remapping keys in Mac OS X 10.4
Authored by: sd on Aug 29, '06 09:30:56AM

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 Aug 29, '06 10:57:46AM

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 Aug 29, '06 03:41:54PM
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 Aug 29, '06 06:37:10PM

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 Aug 30, '06 01:49:06PM

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 Jan 24, '07 06:45:14AM

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 May 09, '08 10:04:30PM

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 Aug 19, '08 04:51:35AM

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 Jul 13, '09 01:56:31PM

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 Sep 15, '09 07:59:05PM
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 | # ]
10.4: Remapping keys in Mac OS X 10.4
Authored by: brianblum on Dec 17, '09 07:04:18AM

I bought a new Apple keyboard which has an extra tilde key to the left of the z and before the shift key which is now much less wide than the standard shift key I'm used to. I'd like to remap the tilde key to the left of my Z to also function as a shift key. Is there any way I can do this?



[ Reply to This | # ]
10.4: Remapping keys in Mac OS X 10.4
Authored by: jdsmith on Dec 09, '11 09:27:25AM
This still works with more recent OSX versions. There is no need to convert the plist to XML, just find the most recent ~/Library/Preferences/ByHost/.GlobalPreferences.*.plist file, open it in the PropertyList Editor (double-click or call with open), find the section(s) com.apple.keyboard.modifiermapping.* (one for each keyboard), open the section, and copy/paste item entries, modifying as indicated in the hint. Save when finished.

For me, I swap Caps Lock and Control, but wanted the right Control key (just left of the arrow keys) to retain functionality as a Control key. So I simply highlighted and deleted the Item mapping between them, and saved; worked perfectly after a logout. Tested on Snow Leopard.

[ Reply to This | # ]