Remap the function keys on the wireless keyboard

Sep 30, '08 07:30:00AM

Contributed by: Anonymous

I just bought a new Apple wireless keyboard, and got annoyed that F4 was hard-wired to the Dashboard, so here's what I did to change it. Warning! Driver hacking follows! Remember to back up the driver first, in order to avoid a possible major malfunction of the keyboard.

In Terminal, do:

sudo vi /System/Library/Extensions/AppleHIDKeyboard.kext
Go to line 349, which is where the function key definitions reside. I haven't fully decoded the system yet, but I think that it works like this: Key,Function. For example:
0x0007003a,0xff010021
0x0007003a is the F1 key without the "fn" key pressed, and 0xff010021 is the code to decrease the screen's brightness. Based on that, here's my ugly hack. I changed 0x0007003d to 0x0007004d -- this apparently made the system think I pressed fn-F4 or something. Either way, it works, and it shows the desktop as I wanted it to.

Save the file and reload the driver with:
kextunload /System/Library/Extensions/AppleHIDKeyboard.kext && kextload /System/Library/Extensions/AppleHIDKeyboard.kext
I'm still working on decoding the "functions" to get full control over my keyboard. For instance, changing 0x0007003d,0xff010002 to 0x0007003d,0x000C00EA works as it should -- it changes the volume as expected.

[robg adds: I haven't tested this one; if you're going to do so, proceed with caution, given you're changing a system driver file.]

Comments (17)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080926082359841