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

10.4: Change keymapping only on external keyboards System 10.4
Tiger only hintThis tip covers how to get Command and Option in the right place on an external PC keyboard, without stuffing them up on the built-in keyboard of a PowerBook. This is of great use to people who dock their laptop with a Windows keyboard, but don't like the "wrong" keyboard layout it produces and tire of constantly changing it back and forth in the system prefs. It would work with iBooks too.

Part A: Getting the external keyboard right
  1. Click the Apple logo and open the System Preferences.
  2. Click the Keyboard & Mouse section, then select Modifier Keys on the Keyboard tab.
  3. Swap the functions for the Option and Command keys.
Now check that the external keyboard works as you would expect. ie. Windows key is now Option, and Windows Alt is now Command. You'll notice that the internal keyboard is now swapped, too, but we'll fix that in a moment.

Part B: Fixing the internal keyboard

Using the instructions from snark.de (no affiliation), we are going to swap the Option and Command keys (again), but this time only on the internal keyboard. Note that it is a very good idea to first back up the file we are going to modify:
cp /System/Library/Extensions/AppleADBKeyboard.kext/Contents/Info.plist \
~/AppleADBKeyboard.backup.plist
  1. Open a Terminal window and run this command:
    sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit \
    /System/Library/Extensions/AppleADBKeyboard.kext/Contents/Info.plist
  2. Find the section ADBVirtualKeys that looks like this:

    0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
    0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
    0x30,0x31,0x32,0x33,0x34,0x35,0x3B,0x37,0x38,0x39,0x3A,0x7B,0x7C,0x7D,0x7E,0x3F,
    0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
    0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
    0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
    0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x3C,0x3D,0x3E,0x36,0x7F

  3. From the guide, we can see that we want to swap 0x37 (Command) and 0x3A (Option), so it looks like this when done:

    0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
    0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
    0x30,0x31,0x32,0x33,0x34,0x35,0x3B,0x3A,0x38,0x39,0x37,0x7B,0x7C,0x7D,0x7E,0x3F,
    0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
    0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
    0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
    0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x3C,0x3D,0x3E,0x36,0x7F

  4. Now you can reboot to apply the changes, or reload the kernel extension. The command to reload the extension is:
    sudo kextunload /System/Library/Extensions/AppleADBKeyboard.kext && \
    sudo kextload /System/Library/Extensions/AppleADBKeyboard.kext
    Note that this must be run as a single command, otherwise you won't be able to type the second part of the command.
Now both the Windows keyboard and the internal keyboard should have the correct key mappings.

Note: There is a comment in the snark.de guide about clearing a bunch of caches so the changes don't revert. I did this, and the changes haven't reverted yet. I wont repeat that info, it's all in the snark.de guide. The changes made may be reset during a system update. Presumably they can just be reapplied after the update. This was tested on a 12" 1.5Ghz Powerbook G4, running OS X 10.4.5.
    •    
  • Currently 3.00 / 5
  You rated: 5 / 5 (4 votes cast)
 
[34,317 views]  

10.4: Change keymapping only on external keyboards | 25 comments | Create New Account
Click here to return to the '10.4: Change keymapping only on external keyboards' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Change keymapping only on external keyboards
Authored by: conrad on Mar 24, '06 07:20:34AM
I'm sorry to ask, but isn't this a repost of my comment from back in July 05?

[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: lucas_ on Mar 25, '06 10:00:10PM

if you're insinuating plagiarism then no, I came up with this based solely on the information of snark.de about remapping the enter key. yes, the link in your post does contain basically the same information; but I certainly didn't come across it when searching for how to do this in the first place. had you made it more prominent perhaps i would have had this problem solved for me in '05, rather solving it myself in March '06. Hopefully this will be of help to others (once the typo is fixed) who never saw your comment with link to blog



[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: petar on Mar 24, '06 08:45:23AM
From the snark.de website:
0x37 for command (the hint mentions 0x38)
0x3A for alt / option
Swapping 0x37 and 0x3A worked for my iBook.
 
Since we're doing this when we have an external keyboard, you can unload the kext before doing the editing.
sudo kextunload /System/Library/Extensions/AppleADBKeyboard.kext
When done editing load it in.

[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: lucas_ on Mar 25, '06 09:49:32PM

right you are, that is a typo. being my first hint im not actually sure if i can edit it, can someone let me know how i would fix that (or perhaps an editor could do it)



[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: robg on Mar 26, '06 04:22:38AM

It's fixed now.



[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: nickvisic on Mar 24, '06 04:05:12PM

man, i am SO upset. i've been looking for a hint like this for 5 years!!!! and now, i can't get it to work!!!!! i have a powerbook g4 400 mhz. old titanium. anybody have an idea what i'm doing wrong?

thanks,
nick



[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: wm on Mar 24, '06 06:43:40PM

What exactly is the behavior that you're seeing? Is it that System Preferences successfully swapped the keys on both keyboards, but you can't get them to de-swap on the internal keyboard? Or do things work as you want if you use kextunload/kextload instead of rebooting, but then revert back when you do reboot? Or....?

And also note that, as petar pointed out, **the hint has a typo**.



[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: nickvisic on Mar 25, '06 07:16:18AM

after i edited, i had to go to disk utilities and repair privilages. once that happened, i then restarted. the external keyboard worked fine, but my laptop keyboard's command and option keys were just not working. i have no idea what they were mapped to, but they didn't work.

thanks,
nick



[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: lucas_ on Mar 25, '06 10:08:22PM
we'll since i only own one powerbook (an Aluminium one) i cant verify that it will work on other models. since you're external keyboard should still be working it shouldnt be to hard to revert the changes if you made a backup:
sudo cp ~/AppleADBKeyboard.backup.plist /System/Library/Extensions/AppleADBKeyboard.kext/Contents/Info.plist
or if you didnt make a backup, just edit the plist file again and swap the two numbers back again.

[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: wm on Mar 26, '06 12:27:17AM

Why did you repair permissions? If you edited the plist using the command given in the hint, you should not have had any permissions issues. It's very important that you don't try to edit it by copying it somewhere else, editing it there, and then copying it back. If you do that, the permissions WILL be wrong, and the OS will not load the kernel extension until you fix the permissions.

At any rate, since you did repair permissions, I assume they are correct and the OS is loading the kernel extension.

So, what is the problem now? Is it that the internal keyboard isn't working at all, or just command and option don't work? I assume it's the latter, since the primary cause for the former would be permissions problems, which you probably don't have. Then, you should double-check that you edited the plist correctly, keeping in mind the fact that there was a typo in the hint.

If the plist is correct, I don't know what the problem is. I've had the enter key on the right side of my 12" PB's keyboard successfully mapped to option for nine months now with no problems whatsoever (aside from having to change the plist back after OS updates that update that kernel extension and thus overwrite my changes). Obviously your Titanium is quite a bit older, but I'm fairly sure that the keyboard works in essentially the same way.



[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: TvE on Mar 25, '06 12:32:55AM

Not knowing WHAT you did makes it pretty much imposible to tell what to do different…



[ Reply to This | # ]
Microsoft Intellitype
Authored by: kaih on Mar 25, '06 01:53:56AM

If you use *gasp* a Microsoft Keyboard, then DO install the IntelliType Software. Get the latest version off Microsoft's website, and then for the MS keyboard, and only the MS keyboard, the Cmd and Opt keys are in the correct place.
I regularly use this, alongside my PowerBook's internal keyboard, and each keyboard has the correct keys in the correct place.

Say what you will about MS, they do make good hardware =)

---
k:.



[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: EatingPie on Mar 25, '06 04:11:47AM

Dare I ask, but wouldn't it be better to change the keymapping on the EXTERNAL keyboard? I don't know how this is done... or if it's possible... but I'd far prefer that solution!

Another tack: What does the "Keyboard & Mouse" Preferences do when you actually use the "Modifier Keys" remap the keys? What does it set and where? Anybody know?

-Pie

---
-Pie
<http://www.storybytes.com>



[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: lucas_ on Mar 25, '06 09:51:57PM

yep, that would be a much cleaner solution, but unfortunately I dont know where to edit the external keymaps. I'd be more that happy for someone to over-shadow this hint and show me though :)



[ Reply to This | # ]
Remapping keys on old Apple USB Keyboards.
Authored by: wizard_drongo on Mar 25, '06 10:11:18AM

I've got one of the old G3 iMac keyboards (tangerine, if you must know) which I use on my desk when my G4 iBook is "docked". Love it, but only one issue;
Does anyone know how to remap the (useless) help/up arrow/pageup/pagedown keys that are on the numpad just above the numlock. I've been searching for over a ear now for a method to remap these 4 keys, ideally to volume up/down/mute and a media eject, as seen on the new Apple keyboards. I don't want to replace my keyboard, just remap 4 keys. Anyone any ideas??



[ Reply to This | # ]
Remapping USB keyboards
Authored by: wm on Mar 26, '06 12:36:45AM
For those looking to remap keys on USB keyboards (including internal keyboards on newer PowerBooks, I suppose), another page on snark.de should help get you started. I have not tried/tested anything on that page, so it might cause your keyboard to burst into flames for all I know. :-)

[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: conrad on Jun 10, '06 07:59:33PM
I've posted new set of instructions for handling both ADB- and USB-based PowerBook keyboards. Modifying the driver is no longer necessary, however a piece of $15 shareware is needed.

[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: af3556 on Jul 05, '06 08:54:53PM
I'll second ControllerMate: works a treat. CM has a tutorial on remapping the keyboard:

http://www.orderedbytes.com/controllermate/help/?show=configkeyboard


[ Reply to This | # ]
sigh..
Authored by: cynikal on Jun 15, '06 04:16:04PM

also have a 15" aluminum powerbook 1.5ghz w/ 10.4.6, tried this hint, worked for a while until i rebooted.. then the key mapping was back to normal.. so i performed the hint again, and once i finished the kernel extension reloading, guess what..

KERNEL PANIC!!!!



[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: lucas_ on Sep 17, '06 02:30:25AM

it might be helpful for anyone still looking to do this, I've since found that installing microsofts intellitype driver gives you the option to do this simply in the system preferences. im not sure if it will work will any usb keyboard or only ms once.

I still use this hack for making that stupid enter key into a forward delete key



[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: vtron on Nov 15, '06 09:15:19AM
I followed everything as stated and it does not work on my PowerBook G4. I looked at the referenced snark.de page which used the same method in order to get rid of the annoying extra enter key next to right command button on the PowerBook. That doesn't work either. In fact when I unload the kernel extention it fails,
sudo kextunload /System/Library/Extensions/AppleADBKeyboard.kext &&sudo kextload /System/Library/Extensions/AppleADBKeyboard.kext
kextunload: unload kext /System/Library/Extensions/AppleADBKeyboard.kext failed

When I load and unload the module, it is successful but the keys are unchanged indicating to me that this extention is not used for anything. Any help is appreciated. THanks V

[ Reply to This | # ]
Does this work on MacBooks?
Authored by: magir on Dec 10, '06 03:16:39AM

I haven't tried yet...



[ Reply to This | # ]
Does not work on MacBooks
Authored by: magir on Dec 10, '06 04:22:22AM

I guess the internal keyboard isn't ADB based anymore (kernel module unload fails and the patch doesn't work) so there's a need for another workaround.



[ Reply to This | # ]
Changing external USB keyboard layouts
Authored by: chendo on Feb 09, '07 07:18:30PM

I had a look myself and I think the AppleUSBTCKeyboard.kext inside /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/

But there's all these different keyboard brands and I have no clue what do edit since the mapping layout is different. Also, your hint doesn't work on the Macbook Pros, or maybe just the C2D ones.



[ Reply to This | # ]
10.4: Change keymapping only on external keyboards
Authored by: earthsaver on Nov 01, '07 06:40:06AM

Note that Heiko Hellweg's (snark.de) hint for internal keyboards was more focused on reassigning the function of the Enter key, since other modifiers are handled by Keyboard Preferences. Well, it works just the same in Leopard. My system kernel panicked about two seconds after the terminal commands completed, but the process worked and I have an Option key there once again.



---
- Ben Rosenthal
PBG4 1.25 - Leopard



[ Reply to This | # ]