Apple wireless keyboard on Linux
The new Apple wireless keyboards are a really nice looking and robust design, but unfortunately, Many people are having trouble using them under Linux.
The main problem is that it times out and people assume that the problem is something to do with the Linux Bluetooth layer. But actually the problem is very easily solved - the keyboard requires a pin number to be established before it will allow the device to connect and bond.
Also, I find that there can be problems connecting to some devices using the GNOME applet by in the system try, so these instructions create the initial connection from a root terminal instead.
First, find the MAC address of your device, as follows:
hcitool scan
This will yield something like the following output:
00:1D:D8:93:90:3D Microsoft Bluetooth Notebook Mouse 5000
00:1E:52:FC:4A:8E Apple Wireless Keyboard
Next, turn on the keyboard, and establish a connection as follows:
hidd --connect 00:1E:52:FC:4A:8E
This is where it would normally time out if left to its own devices, but actually all is well and the keyboard is waiting for you to enter a four digit PIN number such as 0000 into the Apple keyboard followed by the enter key. When you hit enter, a dialog box will come up allowing you to enter the matching PIN (using your currently working keyboard) which will then complete the connection and bonding process.
After this procedure, the keyboard should be listed in the connected and bonded devices list and will automatically be present after rebooting or whenever the keyboard is powered up.
Remapping keys
The Apple wireless keyboard is very compact, but to achieve its small foot print, some often used keys are missing, such as the page up/down, home/end and delete keys. These are emulated by using the fn pseudo-modifier key at the bottom left in combination with the cursor keys (and fn + backspace emulates the delete key). This solution is ok, but I'd like to make a couple of changes for more transparent use with Linux, one change can be done easily, the other can't be done at all.
The one we can't do is to swap the positions of fn and ctrl. Most windows and linux users are used to the control key being at the very bottom right and a function key being next inward not the other way round. But unfortunately the fn key is usually a pseudo-modifier key and has no key code because it doesn't exist as far as the software is concerned - its operation is determined by the keyboard hardware.
- Actually I think this is wrong I think it's done in the kernel not the hardware, cos showkeys gives a result when pressing the fn key.
The change which we can make is to make the eject key into delete since Linux users have no use for eject.You can use xev to find keycodes by pressing keys, and use xmodmap -pke to list current key assignments. The keycode for the eject key on the Apple keyboards is 204, so we can map it to eject as follows:
xmodmap -e "keycode 204 = Delete"
Another one I added was to make the f12 key to the left of eject into an insert key as follows:
xmodmap -e "keycode 176 = Insert"