The Hunting of the Snark

category: encategory: maccategory: tech created: 19. May 2005
modified: 18. Jun. 2005

ADB Keyboard hacks in Mac OSX Tiger (10.4)

In Adapting Mac OSX Tiger i said, simple remappings of modifier keys are possible without actually patching Apples Drivers. This is at least true for ADB Keyboards like those built into current iBooks and PowerBooks. Now that uControl seems not to be developed any further, i have had a couple of request (OK: 2 requests) and thought, i'd write down the details...

Apples own new Keyboard preference allows you to swap alt, option, command and capslock around and for many people, the "capslock-ctrl" feature was the main reason to use uControl at all. Check out Apples own comments in the ADBKeyboard driver about this feature:

//To better support the BSD (hacker) community
// FYI:  The LED will still continue to be controlled by the PMU 
// and change regardless of the state in SW.  While this may not
// be desired, it has been the position of the BSD management and
 // WWDR that the developement community is not concerned.

Other features of uControl like touchpad scrolling are now implemented elsewhere in a different way so Shane Celis is not interested in actively maintaining it.

enterkey.gif This leaves those of us stranded, that just hate the mysterious enter key on Power- and iBooks (the red one on the image to the right). No one could ever tell me, what it is actually good for.

Addition on May 23rd 2005: Just now, this hint on popped up that detailed, what this enter key might originally be meant for... I still need an option key on the right more !

Luckily, Apple provided a hackish but still not too hard way to remap keys on the ADB Keyboard:


In this file, there is a section ADBVirtualKeys that looks like this:


and here, you can actually remap keys permanently (or until an apple update shoots it back again...) by just using the text editor of your choice...

find the 0x34 which is the code for the enter key and replace it with

correction on May 27th 2005: I had previously written 0x36 for control while in fact 0x3b is correct - that was just my poor hadwriting: scribble a small b on a piece of paper - read a 6 later when i type it here... sorry.

Don't add any linefeeds or formatting. leave those hex codes just as they are or the System might not be able to read them properly. Also: be warned: this is a modifiaction of a core system file that may render your machine unusable! While the keyboard driver code tries to have sane fallback rules in case the Info.plist file does not make sense, you might still turn it into that kind of gibberish that is barely acceptable but leaves you with a non-working keyboard. Best keep a spare USB keyboard around in case you mess up (those use another driver that is not affected by these modifications).

Once (after you made a backup of the original of course) you changed this as root and rebooted, your enter key should have turned into another modifier key... Instead of rebooting, you can simply unload and reload your keyboard driver - but be sure to do this in just one command line because once you unloaded it, you won't be able to type the command for loading it again...

sudo /Applications/ /System/Library/Extensions/
sudo kextunload /System/Library/Extensions/AppleADBKeyboard.kext && sudo kextload /System/Library/Extensions/AppleADBKeyboard.kext
This simple hack does not work for remapping from or to the fn key and there is no way to deal differently with left or right modifier keys (ie. remap just the right command key instead) in this setup because both features are handled deep within the keyboard controller. It works the same way in OSX Panther (10.3) by the way.

Addition on June 3rd 2005: I have had a few reports of problems:

sudo rm /System/Library/Extensions.mkext
sudo rm /System/Library/Extensions.kextcache
sudo touch /System/Library/Extensions
sudo touch /System/Library/Extensions/AppleADBKeyboard.kext

I have also had one very weird scenario, where i had changed the enter mpping like described above, rebooted, happily saw that the modification worked, closed the lid of the powerbook so it slept and then - after wakeup - found that the enter mapping had reverted to the previous setting. No traces of this older mapping should have been left on the system so i can not really explain what has happened here (and again: i have not been able to reproduce this ever since). I would be glad, if someone could shed some light on this...

Addition on June 8th 2005: Thanks to a Hint by William Mortensen: If for some reason, your Modifications don't stick, you may also try deleting yet another kernel cache:

sudo rm /System/Library/Caches/*
and/or rebuild it with:
sudo kextcache -c

(c) Heiko Hellweg 2005 - 2009 top