XFree Key Bindings

Modern keyboard offer so called multimedia keys which allow direct control over the browser or media player. But the keycodes which are generated by the individual keys are usually unknown to the system and, therefore, ignored.

By following the steps presented below you will be able to configure and use those keys:

  1. Determine the keycode generated by a key

By running xev from an XTerm press and release events generated by the keyboard are displayed on standard output. The following listing contains the relevant output for a press and release event of the left windows key:

  KeyPress event, serial 28, synthetic NO, window 0x2600001,
  root 0x7d, subw 0x0, time 49070580, (-804,-57), root:(290,0),
  state 0x0, keycode 115 (keysym 0xffeb, Super_L), same_screen YES,
  XLookupString gives 0 bytes:  ""

  KeyRelease event, serial 28, synthetic NO, window 0x2600001,
  root 0x7d, subw 0x0, time 49070684, (-804,-57), root:(290,0),
  state 0x40, keycode 115 (keysym 0xffeb, Super_L), same_screen YES,
  XLookupString gives 0 bytes:  ""
  1. Assigning names to keycodes

The keycodes will then have to assigned a name in ~/.Xmodmap. In my case the windows key becomes an additional meta key (like shift, alt and ctrl)

keycode 115 = Super_L

To assign names to multimedia keys please refer to /usr/X11R6/lib/X11/XKeysymDB which contains numerous names like XF86AudioPlay

After assigned a name to a keycode xfree will have to be notified of the change by running: xmodmap ~/.Xmodmap

  1. Assigning commands to names

To make real use of the newly configured keys use the xbindkeys daemon which listens for press and release events of key names defined in ~/.xbindkeysrc:

  "xscreensaver-command -lock >/dev/null"
  Pause
Feedback is always welcome! If you'd like to get in touch with me concerning the contents of this article, please use Twitter.