XFree Key BindingsPublished on 21 Sep 2003
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:
- Determine the keycode generated by a key
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: ""
- 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
keycode 115 = Super_L
To assign names to multimedia keys please refer to
/usr/X11R6/lib/X11/XKeysymDB which contains numerous names like
After assigned a name to a keycode xfree will have to be notified of the change by running:
- 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
"xscreensaver-command -lock >/dev/null" Pause