Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Remap the function keys on the wireless keyboard Other Hardware
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.]
    •    
  • Currently 1.86 / 5
  You rated: 4 / 5 (7 votes cast)
 
[19,735 views]  

Remap the function keys on the wireless keyboard | 17 comments | Create New Account
Click here to return to the 'Remap the function keys on the wireless keyboard' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Remap the function keys on the wireless keyboard
Authored by: sayler on Sep 30, '08 08:15:37AM

This should be

sudo vi /System/Library/Extensions/AppleHIDKeyboard.kext/Contents/Info.plist

Not

sudo vi /System/Library/Extensions/AppleHIDKeyboard.kext



[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: wallybear on Sep 30, '08 08:23:37AM
Absolutely.
And if you have Developer Tools installed, it would be better to use Property List Editor to edit it.
Even pico is more user friendly than vi.

[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: corienti on Sep 30, '08 10:15:55AM

If you're not the type of person who's already somewhat comfortable with vi, then chances are reasonable that you shouldn't be doing this hint...

FunctionFlip might be a better way to go, if the suggestion to use vi is going to cause an issue.


Disclaimer: have used vi and vim extensively for about 14 years :-)
Nano is pleasant and simple and a great tool for what it is, but it can't do a even a fraction of what vi can do.



[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: leamanc on Oct 01, '08 05:30:51PM

Agreed! I was afraid of vi/vim for years. Last Christmas break, with some time to spare, I sat down and made myself learn to use it, as I often find myself on a *nix box with no pico or nano (or GUI). I'm glad I did it, as I now love it. I even use MacVim for most of my text editing needs these days.



[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: superg on Sep 30, '08 08:35:13AM
What's the advantage of using this over FunctionFlip?

http://www.macworld.com/article/135505/2008/09/functionflip.html

[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: solitario on Sep 30, '08 10:02:56AM

Why not check the option in 'Keyboard and Mouse' labeled something like:

'use the keys 'F1', 'F2', etc. as standard function keys.' (I had to translate from dutch...)



[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: corienti on Sep 30, '08 10:21:03AM

... because that flips ALL the function keys to either F-keys or special-function behaviour.

He only wanted to flip ONE key.

Functionflip does exactly what he wanted, though - I think. I use it myself.

I never use the brightness keys on my iMac and wanted F1/F2 back - but wanted the iTunes keys to work normally though.
Similarly I wanted the brightness keys to work on my MBP, but not the keyboard backlight keys (I can't stand the keyboard backlight, and have it totally disabled).
FunctionFlip does it beautifully.



[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: Dr. T on Sep 30, '08 11:26:19AM

I recommend QuicKeys for those who wish to safely remap any keys. QuicKeys also can be used to make custom launcher palettes (with tabs for groups of applications or files), application-specific palettes, custom menus, keystroke shortcuts, etc. It also plays nice with AppleScript: it can call a script and AppleScript can call a QuicKeys shortcut.

Note: I don't work for Startly Technologies; I've just been a QuicKeys user since OS 7.



[ Reply to This | # ]
Regarding function flip
Authored by: brejwo on Sep 30, '08 11:42:03AM

I have a recent MBP with F3 and F4 mapping to Expose and Dashboard. In function flip I can change all the keys except these two, they don't show up in the list. Is this a problem with function flip or something related to my computer?



[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: davidbk1 on Sep 30, '08 07:54:26PM

can we get a full list of these codes? I'd really like to be able to undo the new layout apple made.



[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: GoboGobo on Oct 01, '08 02:31:23AM

What an incredibly bad hint. This descibes someone hacking a file list, trying out some stuff. Then he finds out "Hey, it works, let's post it!".
Without even a hint of research of what you're doing.

This may be an interesting way to accomplish the same, but I'd rather see some more research on this, since you can really mess up your system this way.

There's lost of other ways to accomplish this, FunctionFlip is one of them (although that doesn't work with all function keys yet iirc).



[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: rycardo on Oct 01, '08 08:05:13AM

I actually appreciate the hint.

There are a range of hints here that are of value to different types of people. I started visiting here when I was a newbie, at the time I appreciated the hints that all the long time mac users didn't appreciate. Now that I'm a more advanced user, I appreciate the more advanced hints.

The hints are pre-screened by rob (et al), they feel they have some value to some people. If you don't appreciate the hint, or it just doesn't do it for you, just ignore it and move on.

In my opinion there is no reason to speak unkindly to someone or their hint.

2ยข



[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: neuralstatic on Oct 01, '08 09:28:36AM

nah, there's nothing wrong with any hint. even if its' totally obvious to some, just bypass it. if you already knew all about the codes, then just walk on by, or join the discussion productively.



[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: darrow on Oct 01, '08 03:51:23AM

What would be ideal is a keyboard combo to toggle the fn key status so you wouldn't even have to use some menu extra to do it.

Is it possible to toggle the fn status at a system level , and attach that script to a key combo ? I sure hope so, any other solution seems cumbersome.





[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: hippybear on Oct 04, '08 06:58:04AM

This already exists. When you change the control panel to switch the function keys to act like real function keys, it tells you there that you just hold down on the "Fn" key (in the block of 6 to the right, with "home" and "end" to get the prebound function of the keys again.



[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: drmacnut on Oct 02, '08 09:56:19PM

Oh well, the hint may indeed be "incredibly bad", as you say GoboGobo, but I see it as good old "poking around fun" as in the days when I used to play around sending POKE commands to the Commodore PET computers our elementary school had (RIP dear PETs), in order to impress my friends. Doing that got me started with 6502 and writing for the C-64 and so on. So in that light, I think this is a cool hint.

Just don't try it if you're a Mac newbie!



[ Reply to This | # ]
Remap the function keys on the wireless keyboard
Authored by: cuban321 on Oct 14, '08 04:51:27PM
http://www.pqrs.org/tekezo/macosx/keyremap4macbook/index.html

That's what I use to accomplish the same thing.

[ Reply to This | # ]