Edit: Skip this post, now there is a better way – see this post: Fixing the numeric keypad directional keys and Ins/Del on a Mac with PC style keyboard, and more Mac commentary
This has nothing to do with the topic of this blog – it’s just something I was trying to figure out recently, and had some VERY limited success so I thought I’d pass along my findings so far. The problem is that if you connect a standard PC keyboard to a Mac mini (or, presumably, any other Mac that uses an external keyboard and runs under OS X), the NumLock key doesn’t work at all, and the numeric keypad produces numbers only, not the directionals or other keys (Ins/Del). After a lot of messing around and head scratching, I figured out that the keyboard mapping is controlled by a file in the /Users/{username}/Keyboard/Roman/ directory (or something similar in certain countries). Assuming you are now using U.S. English, here’s what I have attempted so far (I’m not telling you to do this, but if you try it you are warned it might not work, and therefore you do it at your own risk!):
Copy the file {your language}.keylayout to a safe temporary location and rename it, keeping the same .keylayout extension. Don’t use the name of a country, use your first name or something.
Open it in a text editor and you will see a line like this near the top:
<keyboard group=”0″ id=”0″ name=”U.S.” maxout=”2″>
Edit the ID and name – make the ID something in the 5000 range or above (just use 5000 if you have no reason not to) and make the name your name. So the first three lines will look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<keyboard group="0" id="5000" name="My Layout" maxout="2">
Remember you are editing the copy of the file, not the original!!!
Now look in the first section and find the line that contains key code=”65″ – change it to read:
<key code="65" output="&*#xf728;" />
REMOVE THE ASTERISK IN THE LINE ABOVE – SEE BELOW
Then find the lines for key codes 82 through 92 and change them as follows:
<key code="82" output="&*#xf746;" />
<key code="83" output="&*#xf72b;" />
<key code="84" output="&*#xf701;" />
<key code="85" output="&*#xf72d;" />
<key code="86" output="&*#xf702;" />
<key code="88" output="&*#xf703;" />
<key code="89" output="&*#xf729;" />
<key code="91" output="&*#xf700;" />
<key code="92" output="&*#xf72c;" />
REMOVE THE ASTERISKS IN THE LINES ABOVE – they are just there to keep WordPress from interpreting them as character literals, so where you see &*# change it to &#
Repeat the above for every section in the file that shows those codes (in the U.S. file there were seven)
When you’ve finished making those changes, save the changed file. Then copy it to the /Library/Keyboard Layouts/ directory (if it doesn’t exist, create it). Note this is NOT off the user directory – it’s off the root directory (it might work if you do it off the user directory, but I didn’t try it.
Next, reboot the computer (don’t just logout and back in). Now go to System Preverences, and click on International, then on Input Menu. Find your new file in the list of countries, it should be whatever you named it in the file – not the filename, the name you changed from the country name within the file.
Check the box next to it. It should automatically check the box at the bottom, “Show input menu in menu bar” (check it yourself if it doesn’t). You should see a flag of your country in the menu bar, right click on it and a dropdown should appear that lets you select your new layout.
Now the good news: In many applications, this will let you use the four arrow keys and the Del (delete) key on the numeric keypad. Ins, PgUp, and PgDn might work also if your application uses them. Home and End probably won’t work as you expect. And the bad news? For some reason, the numeric keypad keys still won’t work in some applications, such as the window in Firefox into which I’m typing this post. And the Home and End keys don’t seem to work.
Now, you may think I am using the wrong codes, and you may well be correct, but I can tell you that copying the codes verbatim from those used for the dedicated directional keys (between the main keyboard and the numeric keypad) doesn’t work. I had to use a little utility called Key Codes to see what the keys were actually putting out while depressed, and even then I didn’t really know what I was doing. I had also tried using Ukelele but couldn’t seem to make that work at all – the Mac simply refused to recognize the existence of a file produced by that program (might have something to do with the recent change to Leopard). The truth is, I don’t understand why this is working at all (seriously)!
For me, half a loaf is better than none – I’ll bet I reach for the “wrong” delete key 100 times a day. I know Apple would probably love it if everyone would buy their (highly overpried, IMHO) keyboards, but even those would not give me the functionality I want, and besides, I’ve been using a PC style keyboard for 20 years. In any case I can’t fathom why Apple didn’t anticipate that sme folks might prefer a keyboard they are used to, and that some of those folks might actually want the NumLock key and the directional keys to work as they expect, and in the manner to which they have become accustomed. I never use the numeric keypad to enter numbers (that’s what the keys above the QWERTY line are for) so it doesn’t bother me if I can’t switch back and forth, but I could always switch back to the U.S. keyboard from the top menu bar if I need the numbers anyway.
I’ve been up all night but wanted to post this before catching some sleep, so please excuse if it’s a bit terse, or rough around the edges. Please leave a comment if you feel I didn’t explain something clearly, or made a mistake, or you know a better way to accomplish this (comments such as, “Connect the keyboard to a real PC running Windows” will not be appreciated!). And please let me know if you find a better way to do this!
Edit: Forget everything said above, now there is a better way – see this post: Fixing the numeric keypad directional keys and Ins/Del on a Mac with PC style keyboard, and more Mac commentary
Seven Mac (OS X 10.5) annoyances « Michigan Telephone, VoIP and Broadband blog said
[...] key on the numeric pad), then had to backspace and find the right one. Yes, I finally did find a hack that works in a few programs (Apple Mail for one) but for whatever reason, it doesn’t work in [...]
Seven Mac (OS X 10.5) annoyances | Concepts, Ideas, Thoughts & Bullshit said
[...] key on the numeric pad), then had to backspace and find the right one. Yes, I finally did find a hack that works in a few programs (Apple Mail for one) but for whatever reason, it doesn’t work in [...]