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.

On my Thinkpad laptop I can easily change the Back/Forward keys to something else (I usually map them to PageDown/PageUp), as they have their own keycode (166 and 167):

xmodmap -e 'keycode 166=Prior'
xmodmap -e 'keycode 167=Next'

However, on my Thinkpad USB keyboard, the Back/Forward keys seem to be hard-mapped to Alt+Left and Alt+Right, respectively, so I cannot use xmodmap to remap them. Is there any other way I can remap them? I've already tried xautomation, but that didn't work.

This is what 'xev' shows me when I press the Forward key:

KeyPress event, serial 36, synthetic NO, window 0x4e00001,
    root 0xb4, subw 0x0, time 65023191, (16,-20), root:(641,33),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 36, synthetic NO, window 0x4e00001,
    root 0xb4, subw 0x0, time 65023191, (16,-20), root:(641,33),
    state 0x8, keycode 114 (keysym 0xff53, Right), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x4e00001,
    root 0xb4, subw 0x0, time 65023271, (16,-20), root:(641,33),
    state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x4e00001,
    root 0xb4, subw 0x0, time 65023271, (16,-20), root:(641,33),
    state 0x0, keycode 114 (keysym 0xff53, Right), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False
share|improve this question

migrated from stackoverflow.com Nov 8 '11 at 15:17

This question came from our site for professional and enthusiast programmers.

1  
If the keys have keycode, they can be remapped right? Is it any different than the caps lock key? This page remaps it well it seems. I haven't tried it. Just suggesting. efod.se/writings/linuxbook/html/caps-lock-to-ctrl.html –  Bibhas Jan 18 '12 at 21:11
    
The problem is exactly that it doesn't have a keycode and instead is hard-wired to alt-left/alt-right –  Guilherme Salgado Apr 30 '12 at 14:30

1 Answer 1

up vote 0 down vote accepted
  1. Install xdotool
  2. Create a script or shell alias for the keypress command you want to run (xdotool key --clearmodifiers Page_Down)
  3. Bind that script/alias to the sent combo (Alt+Left) in your desktop environment's Hotkey/Shortcut config.

Note that in gnome-control-center it doesn't seem to be possible to assign the Back/Forward buttons of the USB keyboard to a shortcut (you can actually assign them, but the command/action you mapped to it will never be called/happen), so you might need to use something else, like compiz' Commands plugin.

share|improve this answer
1  
Thanks for the suggestion @sleighboy. I'd tried that with xautomation, but it didn't work. See my own answer, below, as to why –  Guilherme Salgado Apr 30 '12 at 14:56
1  
Actually, this should be the final answer and I'll just explain here why it didn't work. The command to run should be xdotool key --clearmodifiers Page_Up and for some reason assigning the Back/Forward button as the accelerator of a shortcut on gnome-control-center doesn't seem to work, but if you use compiz' 'Commands' plugin it will work. –  Guilherme Salgado Apr 30 '12 at 15:29
    
Thanks for the edit and comments. –  SleighBoy May 2 '12 at 4:34

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.