Some Apple keyboard models may have swapped keys or missing functionality. This article describes how to change the settings for the keyboard so that it behaves as expected.
- 1 Numlock is on
- 2 Repeating keys on a wireless keyboard
- 3 Function keys do not work
- 4 Switching Cmd and Alt/AltGr
- 5 < and > have changed place with § and ½
- 6 < and > have changed place with ^ and ° (or @ and #, or ` and ~)
- 7 PrintScreen and SysRq
- 8 Treating Apple keyboards like regular keyboards
- 9 Magic Keyboard does not connect
- 10 See also
Numlock is on
You may find that the numlock is on. The symptoms are that only the physical keys
l and surrounding keys work and output numbers. To fix this hit
Alternatively, set the keycodes manually using xmodmap to avoid use Numlock:
keycode 90 = KP_0 KP_0 KP_0 KP_0 KP_0 KP_0 keycode 87 = KP_1 KP_1 KP_1 KP_1 KP_1 KP_1 keycode 88 = KP_2 KP_2 KP_2 KP_2 KP_2 KP_2 keycode 89 = KP_3 KP_3 KP_3 KP_3 KP_3 KP_3 keycode 83 = KP_4 KP_4 KP_4 KP_4 KP_4 KP_4 keycode 84 = KP_5 KP_5 KP_5 KP_5 KP_5 KP_5 keycode 85 = KP_6 KP_6 KP_6 KP_6 KP_6 KP_6 keycode 79 = KP_7 KP_7 KP_7 KP_7 KP_7 KP_7 keycode 80 = KP_8 KP_8 KP_8 KP_8 KP_8 KP_8 keycode 81 = KP_9 KP_9 KP_9 KP_9 KP_9 KP_9
Repeating keys on a wireless keyboard
Unpair the keyboard and then re-pair it. The trick is to hold down the power button throughout the entire pairing process.
Function keys do not work
F<num> keys do not work, this is probably because the kernel driver for the keyboard has defaulted to using the media keys and requiring you to use the
Fn key to get to the
F<num> keys. To change the behavior temporarily, append
# echo 2 > /sys/module/hid_apple/parameters/fnmode
To make the change permanent, set the
fnmode option to 2:
options hid_apple fnmode=2
To apply the change to your initial ramdisk, in your mkinitcpio configuration (usually
/etc/mkinitcpio.conf), make sure you either have
modconf included in the
HOOKS variable or
/etc/modprobe.d/hid_apple.conf in the
FILES variable. You would then need to regenerate the initramfs.
Switching Cmd and Alt/AltGr
This will switch the left
Cmd key as well as the right
Temporary and immediate solution:
# echo "1" > /sys/module/hid_apple/parameters/swap_opt_cmd
Permanent change, taking place at next reboot:
options hid_apple swap_opt_cmd=1
You then need to regenerate the initramfs.
< and > have changed place with § and ½
If the < and > are switched with the § and ½ keys, set the xkb option
apple:badmap, for instance by running the following command in your graphical environment:
$ setxkbmap -option apple:badmap
Alternatively, set the keycodes manually using xmodmap:
keycode 49 = less greater less greater bar brokenbar keycode 94 = section degree section degree notsign notsign
If you use a Canadian multilingual layout (where the "ù" and the "/" is switch) use this:
keycode 94 = slash backslash slash backslash bar brokenbar keycode 49 = ugrave Ugrave ugrave Ugrave notsign notsign
< and > have changed place with ^ and ° (or @ and #, or ` and ~)
With German layout, circumflex/degree symbol and </> are exchanged. With French layout, @/# are exchanged. With the US layout, `/~ and </> are exchanged.
PrintScreen and SysRq
Apple Keyboards have an
F13 key instead of a
SysRq key. This means that Alt+SysRq sequences do not work, and application actions associated with
PrintScreen (such as taking screenshots in many games that work under Wine) do not work. To fix this, you can add
setxkbmap -option "apple:alupckeys" to your
.xinitrc. This will map
F13, as well as
Scroll lock to
Alternatively, follow the Map scancodes to keycodes article to map the
F13 scancode to the
SysRq keycode, where 458856 (0x070068) is the scancode of
sysrq is the keycode of
Treating Apple keyboards like regular keyboards
Depending on the customisations you want to accomplish, there are two solutions available. You need to choose one of the other.
Use a patch to hid-apple
While the original
hid-apple module does not have options to further customize the keyboard, like swapping
Fn and left
Ctrl keys or having
Alt on the left side of
Super, there is a patch adding this functionality to the module. To install the patch, install the AUR package.
In addition to the patched kernel module, a configuration file is also provided by the package at
/etc/modprobe.d/hid_apple_pclayout.conf, which enables PC-like layout by default:
- Top-row keys are normally function keys, switchable to media keys by holding Fn key, as in #Function keys do not work.
- Four keys at the lower left corner act as
Alt, in this order.
Altkeys on the right are swapped.
- If you have an
Ejectcdkey, it will act as
Please refer to https://github.com/free5lot/hid-apple-patched#configuration for exact meaning of each configuration options and tweaking the configuration file to suit your need.
modconf) about how to do that.
After installation the change is not picked up by the kernel immediately. The simplest way is to just reboot your system and the new behavior should be in effect.
If you do not need all of these customizations and you do not want to compile a new module manually or using dkms, there is an AUR packageAUR which does not rely on a new kernel module, but rather just to mappings. It enables the following features:
- The keyboard is considered as an ISO keyboard (e.g.
>located at the right of the
Left Shiftkey are working like expected).
- The function keys are disabled by default. You need to press the
Fnkey in combination to trigger them. By default, the behavior are thus keys
Cmdkeys are swapped.
F13is mapped to
The first 3 aforementioned features are brought to you using the default linux kernel module
The last one is provided by providing a mapping toAUR.
Change the Behavior Without Reboot
To reload the kernel module without reboot, run
rmmod hid_apple && modprobe hid_apple.
Magic Keyboard does not connect
If you have a magic keyboard that will not connect to the system through the built in tools, such as the Gnome 3 bluetooth menu in settings, installand its dependencies and attempt to connect with it. If it still fails to connect, make sure you have bluetoothctl and hcitool installed.