Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

How can I use these keys as shortcuts?

share|improve this question
add comment

1 Answer

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.

share|improve this answer
    
You might be able to skip step 2 completely, which is always nice. –  Rob May 17 '12 at 17:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.