Difference between revisions of "Apple Keyboard"

From ArchWiki
Jump to: navigation, search
(Added a method to fix the §<>\ problem with international aluminum apple keyboards)
(Remove style template - I think I've fixed most of it now.)
 
(60 intermediate revisions by 21 users not shown)
Line 1: Line 1:
 
[[Category:Keyboards]]
 
[[Category:Keyboards]]
 +
[[ja:Apple Keyboard]]
 +
{{Related articles start}}
 +
{{Related|Extra_keyboard_keys}}
 +
{{Related articles end}}
  
== More Information ==
+
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.
Also see this page: https://help.ubuntu.com/community/AppleKeyboard
+
  
==Function keys do not work==
+
== Numlock is on ==
  
If your 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 this behaviour, you have to change a driver setting. Do the following as root:
+
You may find that the numlock is on. The symptoms are that only the physical keys 7,8,9,u,i,o,j,k,l and surrounding keys work and output numbers. To fix this hit {{ic|Fn}}+{{ic|F6}} twice.
  
echo 2 > /sys/module/hid_apple/parameters/fnmode
+
== Repeating keys on a wireless keyboard ==
  
If it tells you that the file doesn't exist, you probably have an older kernel and will have to do the following instead:
+
Unpair the keyboard and then re-pair it. The trick is to hold down the power button throughout the entire pairing process.
  
echo 2 > /sys/module/hid/parameters/pb_fnmode
+
== Function keys do not work ==
  
Place whichever command worked for you in {{ic|/etc/rc.local}} to make the setting permanent.
+
If your {{ic|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 {{ic|Fn}} key to get to the {{ic|F<num>}} keys. To change the behavior temporarily, [[Help:Reading#Append.2C_add.2C_create.2C_edit|append]] {{ic|2}} to {{ic|/sys/module/hid_apple/parameters/fnmode}}. To make the change permanent, [[Kernel_modules#Setting_module_options|set]] the {{ic|hid_apple}} {{ic|fnmode}} option to 2.
  
===If the above doesn't work for you===
+
== < and > have changed place with § and ½ ==
  
If hid_apple/parameters and/or hid/parameters/pb_fnmode is missing in a recent Apple Bluetooth keyboard model and recent kernel (3.4)...
+
If the '''<''' and '''>''' are switched with the '''§''' and '''½''' keys, [[Keyboard_configuration_in_Xorg|set the xkb option]] {{ic|apple:badmap}}, for instance by running the following command in your graphical environment:
  
First thing: identify your keyboard. Execute as root:
+
  $ setxkbmap -option apple:badmap
  hidd --show
+
  
You should see something like:
+
Alternatively, set the keycodes manually using [[xmodmap]]:
40:CA:EC:32:85:AB Apple Wireless Keyboard [05ac:0255] connected
+
 
+
So with the vendor (05ac) and device (0255) ID it's easier to find out if the current kernel has support for it.
+
Actually, the above device is listed in the linux kernel 3.4. If you check drivers/hid/hid-ids.h you should see the following line:
+
+
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI  0x0255
+
 
+
But support for the Function Key is missing.
+
 
+
In order to fix it rebuild your kernel from abs with the following patch:
+
http://pastebin.com/CvFJz3Fn
+
 
+
This bug is already reported upstream.
+
https://bugzilla.kernel.org/show_bug.cgi?id=43135
+
 
+
==< and > have changed place with § and ½==
+
 
+
If the '''<''' and '''>''' are switched with the '''§''' and '''½''' keys, run the following command:
+
 
+
setxkbmap -option apple:badmap
+
 
+
Place that command into {{ic|~/.bashrc}} file to have it run automatically when you log in.
+
 
+
You can also apply the change system-wide by creating (or editing) {{ic|/etc/X11/xorg.conf.d/10-keymap.conf}} as such:
+
Section "InputClass"
+
    Identifier "keyboard catchall"
+
    MatchIsKeyboard "true"
+
    Driver "evdev"
+
    Option "XkbOptions" "apple:badmap"
+
EndSection
+
 
+
 
+
If the above approach doesn't seem to work, you can add these two lines to your {{ic|~/.Xmodmap}} file:
+
  
 
  keycode  49 = less greater less greater bar brokenbar
 
  keycode  49 = less greater less greater bar brokenbar
 
  keycode  94 = section degree section degree notsign notsign
 
  keycode  94 = section degree section degree notsign notsign
  
If you use a Canadian multilingual layout (where the "ù" and the "/" is switch) use this :
+
If you use a Canadian multilingual layout (where the "ù" and the "/" is switch) use this:
  
 
  keycode  94 = slash backslash slash backslash bar brokenbar
 
  keycode  94 = slash backslash slash backslash bar brokenbar
 
  keycode  49 = ugrave Ugrave ugrave Ugrave notsign notsign
 
  keycode  49 = ugrave Ugrave ugrave Ugrave notsign notsign
  
Then run {{Ic|xmodmap ~/.Xmodmap}}. This command can also go into {{ic|~/.bashrc}}.
+
== < and > have changed place with ^ and ° (or @ and #, or ` and ~) ==
  
==< and > have changed place with ^ and °==
+
With German layout, circumflex/degree symbol and </> are exchanged. With French layout, @/# are exchanged. With the US layout, `/~ and </> are exchanged.
With German layout, circumflex/degree symbol and 'smaller than'/'bigger than' are exchanged.
+
  
'''The new way:'''
+
To change the behavior temporarily, [[Help:Reading#Append.2C_add.2C_create.2C_edit|append]] {{ic|0}} to {{ic|/sys/module/hid_apple/parameters/iso_layout}}. To make the change permanent, [[Kernel_modules#Setting_module_options|set]] the {{ic|hid_apple}} {{ic|iso_layout}} option to 0.
  
First, try if the new method works for you (you have to be root)
+
== PrintScreen and SysRq ==
echo 0 | tee /sys/module/hid_apple/parameters/iso_layout
+
To make the changes permanent:
+
echo options hid_apple iso_layout=0 | tee -a /etc/modprobe.d/hid_apple.conf
+
  
'''To fix this the old way, do the following:'''
+
Apple Keyboards have an {{ic|F13}} key instead of a {{ic|PrintScreen}}/{{ic|SysRq}} key. This means that [[Keyboard shortcuts#Kernel|Alt+SysRq sequences]] do not work, and application actions associated with {{ic|PrintScreen}} (such as taking screenshots in many games that work under [[Wine]]) do not work. To fix this, [[Map_scancodes_to_keycodes|map the {{ic|F13}} scancode to the {{ic|PrintScreen}}/{{ic|SysRq}} keycode]], where 458856 (0x070068) is the scancode of {{ic|F13}}, and 99 is the keycode of {{ic|PrintScreen}}/{{ic|SysRq}}.
xmodmap -e 'keycode 49 = less greater less greater bar brokenbar bar' -e 'keycode 94 = dead_circumflex degree dead_circumflex degree U2032 U2033 U2032'
+
  
Now try your keys. When it works, you may want the change permanently. So execute this:
+
== Treating Apple keyboards like regular keyboards ==
xmodmap -pke | grep " 49" >> ~/.Xmodmap
+
xmodmap -pke | grep " 94" >> ~/.Xmodmap
+
  
==Media Keys==
+
If you want to use your Apple keyboard like a regular US-layout keyboard, with {{ic|Alt}} on the left side of {{ic|Meta}}, you can use the [[AUR]] package {{AUR|un-apple-keyboard}}.  Currently it only works for the aluminium USB model.  The package does the following things:
  
The evdev driver should produce keycodes that map to the appropriate keysyms for your media keys by default. You can confirm that by running {{Ic|xev}} in a console window and watching the console output as you press your media keys.
+
*Adds a {{ic|/etc/modprobe.d/hid_apple.conf}} file which enables the {{ic|F<num>}} keys by default, as in [[#Function keys do not work]].
 +
*Uses keyfuzz to remap {{ic|F13-15}} to {{ic|PrintScreen}}/{{ic|SysRq}}, {{ic|Scroll Lock}}, and {{ic|Pause}}, respectively.
 +
*Swaps the ordering of the {{ic|Alt}} and {{ic|Meta}} ({{ic|Command}}) keys to match all other keyboards, again using {{ic|/etc/modprobe.d/hid_apple.conf}}, as in [[#Swap the Alt key and Command key (Meta/Super)]].
 +
*Applies these changes automatically when you plug in your keyboard, with a [[udev]] rule.
  
For these keys to have any effect, you will have to assign actions to them. Refer to [[Extra Keyboard Keys in Xorg]] for more about that.
+
{{Accuracy|The udev rule should take care of the keyboard when it is plugged in at boot}}
  
 +
You will need to add {{ic|/etc/modprobe.d/hid_apple.conf}} to FILES in [[mkinitcpio.conf]]. Otherwise if you boot your computer with the Apple keyboard plugged in, the the {{ic|F<num>}} keys will not work by default.
  
If you have confirmed that your media keys are ''not'' producing the correct keycodes, create or edit the {{ic|~/.Xmodmap}} file so that it includes these lines:
+
== Swap the Alt key and Command key (Meta/Super) ==
<pre>
+
keycode 160 = XF86AudioMute
+
keycode 176 = XF86AudioRaiseVolume
+
keycode 174 = XF86AudioLowerVolume
+
  
keycode 144 = XF86AudioPrev
+
To change the behavior temporarily, [[Help:Reading#Append.2C_add.2C_create.2C_edit|append]] {{ic|1}} to {{ic|/sys/module/hid_apple/parameters/swap_opt_cmd}}. To make the change permanent, [[Kernel_modules#Setting_module_options|set]] the {{ic|hid_apple}} {{ic|swap_opt_cmd}} option to 1.
keycode 162 = XF86AudioPlay
+
keycode 153 = XF86AudioNext
+
  
keycode 101 = XF86MonBrightnessDown
+
== Swap the Fn key and Left Ctrl key ==
keycode 212 = XF86MonBrightnessUp
+
  
keycode 204 = XF86Eject
+
While the original {{ic|hid-apple}} module doesn't have an option to swap the fn and left control keys, there is a [https://github.com/free5lot/hid-apple-patched patch] adding this functionality to the module. To install the patch, [[install]] the {{AUR|hid-apple-patched-git}} package.
</pre>
+
and then run {{Ic|xmodmap ~/.Xmodmap}}. Place that command in the {{ic|~/.bashrc}} file to have it run automatically when you log in.
+
  
==PrintScreen and SysRq==
+
To change the behavior temporarily, [[Help:Reading#Append.2C_add.2C_create.2C_edit|append]] {{ic|1}} to {{ic|/sys/module/hid_apple/parameters/swap_fn_leftctrl}}. To make the change permanent, [[Kernel_modules#Setting_module_options|set]] the {{ic|hid_apple}} {{ic|swap_fn_leftctrl}} option to 1.
  
Apple Keyboards have an F13 key instead of a PrintScreen/SysRq key. This means that [[Keyboard Shortcuts#Kernel | 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.
+
{{Note|
Both issues can be addressed by installing {{AUR|keyfuzz}} from the [[Arch User Repository]].
+
*The default configuration provided in {{AUR|hid-apple-patched-git}} also swaps the left option and command keys so you don't have to follow [[#Swap the Alt key and Command key (Meta/Super)]] to do that.
 +
*This {{AUR|hid-apple-patched-git}} also provides an option to use ejectcd key as the missing delete key on Apple keyboard. It is enabled by default through the {{ic|1=ejectcd_as_delete=1}} option.}}
  
With keyfuzz installed, run the following command:
+
== See also ==
echo "458856 99" | /usr/sbin/keyfuzz -s -d /dev/input/by-id/usb-Apple__Inc_Apple_keyboard-event-kbd
+
458856 (0x070068) is the scancode of F13, and 99 is the keycode of PrintScreen/SysRq.  You can determine the scancode of a particular key with {{AUR|getscancodes}} from the AUR, and the keycode from /usr/include/linux/input.h.
+
 
+
Other versions of the Apple Aluminum Keyboard may require a slightly different device path, so adjust it as needed. You can make this change permanent by putting the command in {{ic|/etc/rc.local}}.
+
 
+
==Treating Apple Keyboards Like Regular Keyboards==
+
 
+
If you want to use your Apple keyboard like a regular US-layout keyboard, with Alt on the left side of Meta, you can use the AUR package {{AUR|un-apple-keyboard}}.  Currently it only works for the aluminium USB model.  The package does the following things:
+
 
+
*Adds a {{ic|/etc/modprobe.d/hid_apple.conf}} file which enables the F keys by default, as above.
+
*Uses keyfuzz to remap F13-15 to PrintScreen/SysRq, Scroll Lock, and Pause, respectively
+
*Swaps the ordering of the {{Keypress|Alt}} and {{Keypress|Meta}} ({{Keypress|Command}}) keys to match all other keyboards, again using keyfuzz.
+
*Applies these changes automatically when you plug in your keyboard, with a [[udev]] rule.
+
  
You will need to add /etc/modprobe.d/hid_apple.conf to FILES in [[mkinitcpio.conf]].  Otherwise if you boot your computer with the Apple keyboard plugged in, the F keys will not be the default.
+
*https://help.ubuntu.com/community/AppleKeyboard

Latest revision as of 21:54, 18 November 2016

Related articles

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.

Numlock is on

You may find that the numlock is on. The symptoms are that only the physical keys 7,8,9,u,i,o,j,k,l and surrounding keys work and output numbers. To fix this hit Fn+F6 twice.

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

If your 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 2 to /sys/module/hid_apple/parameters/fnmode. To make the change permanent, set the hid_apple fnmode option to 2.

< 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.

To change the behavior temporarily, append 0 to /sys/module/hid_apple/parameters/iso_layout. To make the change permanent, set the hid_apple iso_layout option to 0.

PrintScreen and SysRq

Apple Keyboards have an F13 key instead of a PrintScreen/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, map the F13 scancode to the PrintScreen/SysRq keycode, where 458856 (0x070068) is the scancode of F13, and 99 is the keycode of PrintScreen/SysRq.

Treating Apple keyboards like regular keyboards

If you want to use your Apple keyboard like a regular US-layout keyboard, with Alt on the left side of Meta, you can use the AUR package un-apple-keyboardAUR. Currently it only works for the aluminium USB model. The package does the following things:

  • Adds a /etc/modprobe.d/hid_apple.conf file which enables the F<num> keys by default, as in #Function keys do not work.
  • Uses keyfuzz to remap F13-15 to PrintScreen/SysRq, Scroll Lock, and Pause, respectively.
  • Swaps the ordering of the Alt and Meta (Command) keys to match all other keyboards, again using /etc/modprobe.d/hid_apple.conf, as in #Swap the Alt key and Command key (Meta/Super).
  • Applies these changes automatically when you plug in your keyboard, with a udev rule.

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: The udev rule should take care of the keyboard when it is plugged in at boot (Discuss in Talk:Apple Keyboard#)

You will need to add /etc/modprobe.d/hid_apple.conf to FILES in mkinitcpio.conf. Otherwise if you boot your computer with the Apple keyboard plugged in, the the F<num> keys will not work by default.

Swap the Alt key and Command key (Meta/Super)

To change the behavior temporarily, append 1 to /sys/module/hid_apple/parameters/swap_opt_cmd. To make the change permanent, set the hid_apple swap_opt_cmd option to 1.

Swap the Fn key and Left Ctrl key

While the original hid-apple module doesn't have an option to swap the fn and left control keys, there is a patch adding this functionality to the module. To install the patch, install the hid-apple-patched-gitAUR package.

To change the behavior temporarily, append 1 to /sys/module/hid_apple/parameters/swap_fn_leftctrl. To make the change permanent, set the hid_apple swap_fn_leftctrl option to 1.

Note:

See also