Difference between revisions of "Apple Keyboard"

From ArchWiki
Jump to: navigation, search
(Keysym mapping: evdev driver produces correct keycodes for media keys by default)
(Add section about PrintScreen/SysRq. Use Codeline and Filename templates.)
Line 1: Line 1:
 
[[Category:Input devices (English)]]
 
[[Category:Input devices (English)]]
== Function keys don't work ==
+
==Function keys don't 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 this behaviour, you have to change a driver setting. Do the following as root:
 
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:
  
Line 9: Line 10:
 
  echo 2 > /sys/module/hid/parameters/pb_fnmode
 
  echo 2 > /sys/module/hid/parameters/pb_fnmode
  
Place whichever command worked for you in '''/etc/rc.local''' to make the setting permanent.
+
Place whichever command worked for you in {{Filename|/etc/rc.local}} to make the setting permanent.
 
+
  
 
==< and > have changed place with § and ½==
 
==< and > have changed place with § and ½==
 +
 
If the '''<''' and '''>''' are switched with the '''§''' and '''½''' keys, run the following command:
 
If the '''<''' and '''>''' are switched with the '''§''' and '''½''' keys, run the following command:
  
 
  setxkbmap -option apple:badmap
 
  setxkbmap -option apple:badmap
  
Place that command into '''~/.bashrc''' file to have it run automatically when you log in.
+
Place that command into {{Filename|~/.bashrc}} file to have it run automatically when you log in.
  
You can also apply the change system-wide by creating (or editing) '''/etc/X11/xorg.conf.d/10-keymap.conf''' as such:
+
You can also apply the change system-wide by creating (or editing) {{Filename|/etc/X11/xorg.conf.d/10-keymap.conf}} as such:
 
  Section "InputClass"
 
  Section "InputClass"
 
     Identifier "keyboard catchall"
 
     Identifier "keyboard catchall"
Line 28: Line 29:
  
  
If the above approach doesn't seem to work, you can add these two lines to your '''~/.Xmodmap''' file:
+
If the above approach doesn't seem to work, you can add these two lines to your {{Filename|~/.Xmodmap}} file:
  
 
  keycode  49 = less greater less greater bar brokenbar
 
  keycode  49 = less greater less greater bar brokenbar
Line 38: Line 39:
 
  keycode  49 = ugrave Ugrave ugrave Ugrave notsign notsign
 
  keycode  49 = ugrave Ugrave ugrave Ugrave notsign notsign
  
Then run '''xmodmap ~/.Xmodmap'''. This command can also go into '''~/.bashrc'''.
+
Then run {{Codeline|xmodmap ~/.Xmodmap}}. This command can also go into {{Filename|~/.bashrc}}.
  
== Media Keys ==
+
==Media Keys==
  
The evdev driver should produce keycodes that map to the appropriate keysyms for your media keys by default. You can confirm that by running '''xev''' in a console window and watching the console output as you press your media keys.
+
The evdev driver should produce keycodes that map to the appropriate keysyms for your media keys by default. You can confirm that by running {{Codeline|xev}} in a console window and watching the console output as you press your media keys.
  
 
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.
 
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.
  
  
If you have confirmed that your media keys are ''not'' producing the correct keycodes, create or edit the '''~/.Xmodmap''' file so that it includes these lines:
+
If you have confirmed that your media keys are ''not'' producing the correct keycodes, create or edit the {{Filename|~/.Xmodmap}} file so that it includes these lines:
 
<pre>
 
<pre>
 
keycode 160 = XF86AudioMute
 
keycode 160 = XF86AudioMute
Line 62: Line 63:
 
keycode 204 = XF86Eject
 
keycode 204 = XF86Eject
 
</pre>
 
</pre>
and then run '''xmodmap ~/.Xmodmap'''. Place that command in the '''~/.bashrc''' file to have it run automatically when you log in.
+
and then run {{Codeline|xmodmap ~/.Xmodmap}}. Place that command in the {{Filename|~/.bashrc}} file to have it run automatically when you log in.
 +
 
 +
==PrintScreen and SysRq==
 +
 
 +
Apple Keyboards have an F13 key instead of a PrintScreen/SysRq key. This means that [[Keyboard Shortcuts#Kernel | Alt+SysRq sequences]] don't work, and application actions associated with PrintScreen (such as taking screenshots in many games that work under [[Wine]]) don't work.
 +
Both issues can be addressed by installing [http://aur.archlinux.org/packages.php?ID=19800 keyfuzz] from AUR.
 +
 
 +
With keyfuzz installed, run the following command:
 +
echo "458856 99" | /usr/sbin/keyfuzz -s -d /dev/input/by-id/usb-Apple__Inc_Apple_keyboard-event-kbd
 +
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 {{Filename|/etc/rc.local}}.

Revision as of 21:05, 1 September 2011

Function keys don't 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 this behaviour, you have to change a driver setting. Do the following as root:

echo 2 > /sys/module/hid_apple/parameters/fnmode

If it tells you that the file doesn't exist, you probably have an older kernel and will have to do the following instead:

echo 2 > /sys/module/hid/parameters/pb_fnmode

Place whichever command worked for you in Template:Filename to make the setting permanent.

< 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 Template:Filename file to have it run automatically when you log in.

You can also apply the change system-wide by creating (or editing) Template:Filename 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 Template:Filename file:

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

Then run Template:Codeline. This command can also go into Template:Filename.

Media Keys

The evdev driver should produce keycodes that map to the appropriate keysyms for your media keys by default. You can confirm that by running Template:Codeline in a console window and watching the console output as you press your media keys.

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.


If you have confirmed that your media keys are not producing the correct keycodes, create or edit the Template:Filename file so that it includes these lines:

keycode 160 = XF86AudioMute
keycode 176 = XF86AudioRaiseVolume
keycode 174 = XF86AudioLowerVolume

keycode 144 = XF86AudioPrev
keycode 162 = XF86AudioPlay
keycode 153 = XF86AudioNext

keycode 101 = XF86MonBrightnessDown
keycode 212 = XF86MonBrightnessUp

keycode 204 = XF86Eject

and then run Template:Codeline. Place that command in the Template:Filename file to have it run automatically when you log in.

PrintScreen and SysRq

Apple Keyboards have an F13 key instead of a PrintScreen/SysRq key. This means that Alt+SysRq sequences don't work, and application actions associated with PrintScreen (such as taking screenshots in many games that work under Wine) don't work. Both issues can be addressed by installing keyfuzz from AUR.

With keyfuzz installed, run the following command:

echo "458856 99" | /usr/sbin/keyfuzz -s -d /dev/input/by-id/usb-Apple__Inc_Apple_keyboard-event-kbd

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 Template:Filename.