Bind multimedia keys

1

1

I've got an old keyboard (Compaq 9009) with multimedia keys.

How can I use these keys as shortcuts?

oneat

Posted 2012-05-17T17:03:06.563

Reputation: 2 823

Answers

3

In short steps:

  1. Find the keycode using e.g. xev. Just start xev from a terminal and press the relevant button and note the key code, e.g.

    KeyPress event, serial 36, synthetic NO, window 0x2400001,
    root 0x15a, subw 0x0, time 1566086412, (15,210), root:(634,738),
    state 0x10, keycode 78 (keysym 0xff14, Scroll_Lock), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False
    

    when pressing scroll lock. Note keycode 78. If you already get the "human readable" name in following parenthesis such as "Scroll_Lock" above, your keys already "work" as much as X recognizes them as distinct keys. If so, jump to 3.

  2. Add the key codes to ~/.Xmodmap. Sample syntax:

    keycode 144 = XF86AudioPrev
    keycode 153 = XF86AudioNext
    keycode 176 = XF86AudioRaiseVolume
    keycode 174 = XF86AudioLowerVolume
    
  3. This is window manager specific. You mentioned Xfce. From e.g. the Gentoo wiki for Xfce:

    Go to Settings > Keyboard Settings, and select the "Shortcuts" tab. To define our own key bindings, we have to create a new theme. Click "Add" to create it (note that all key bindings from the default theme are copied into the new theme). In the "Command Shortcuts" section, doubleclick on an empty slot, enter the command you would like to bind and press the according key. The keysym from your .Xmodmap should appear next to the command if everything works as expected. Done.

All in all, the Gentoo wiki on multimedia keys seems to be good for more elaborate instructions.

Daniel Andersson

Posted 2012-05-17T17:03:06.563

Reputation: 20 465

You might be able to skip step 2 completely, which is always nice. – Rob – 2012-05-17T17:44:10.227