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
Nicolas Raoul
  • 11,603

1 Answers1

23

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=
Isaiah
  • 59,344
  • Works great :-) – Nicolas Raoul Feb 02 '11 at 07:54
  • 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 07 '12 at 09:08
  • This works on my ThinkPad X220 too. Thanks! – Joe May 08 '12 at 18: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. – Nicolas Raoul Jun 29 '12 at 04:49
  • How can I map them to do something like ctrl+right_arrow? – K1. Jun 11 '13 at 05:34
  • 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 02 '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 http://askubuntu.com/questions/325272/permanent-xmodmap-in-ubuntu-13-04 . If anyone can give comprehensible instructions on how to disable these keys with XKB that would be great. – JDiMatteo Jul 10 '15 at 00:16