21

My Thinkpad R500 has back/forward keys just about the direction keys, so on Firefox I keep losing entered text, accidentally.

How to disable these back/forward keys?

Excerpt from xev:

KeyPress event, serial 29, synthetic NO, window 0x5e00001,
    root 0xbc, subw 0x0, time 2375874, (1279,794), root:(1285,881),
    state 0x10, keycode 166 (keysym 0x1008ff26, XF86Back), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False
KeyPress event, serial 32, synthetic NO, window 0x5e00001,
    root 0xbc, subw 0x0, time 2377115, (1279,794), root:(1285,881),
    state 0x10, keycode 167 (keysym 0x1008ff27, XF86Forward), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False
22

You can disable keys using the xmodmap command. For example, to disable XF86Back, run the following command:

xmodmap -e "keycode 166="

This sets the keycode 166 (Which is the keycode for XF86Back as you can see in the xev output) to nothing, which means it is disabled. To re-enable XF86Back:

xmodmap -e "keycode 166=XF86Back"

To disable both the Back and Forward keys automatically, create the file .xmodmap in your home folder and paste the following inside it:

keycode 166=
keycode 167=
8
  • 7
    I could also suggest you to sue them as Home and End keys. This works great for text editing on my ThinkPad. Simply set the keycode equal to Home and End.
    – Rasmus
    Mar 7 '12 at 9:08
  • 2
    @Rasmus: "sue them" haha "use them" I guess ;-) Yes, this makes a lot of sense and is useful under vim or terminal as well. To make sure everyone understands, it is keycode 166=Home and keycode 167=End. Jun 29 '12 at 4:49
  • 1
    xmodmap -e "keycode 166=" works perfectly, but when I add the file .xmodmap with the contents to my home the back and forward still working. am I missing something here?
    – Husni
    Aug 23 '13 at 12:29
  • 2
    @Husni: same here. Looks like the name varies. On some systems it's .xmodmaprc, on Ubuntu it appears to be .Xmodmap since oneiric.
    – Mu Mind
    Nov 2 '13 at 23:40
  • 1
    Unfortunately, .xmodmap home files do not work with recent versions of Ubuntu (it doesn't matter what name you use), see askubuntu.com/questions/325272/… . If anyone can give comprehensible instructions on how to disable these keys with XKB that would be great.
    – JDiMatteo
    Jul 10 '15 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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