How to disable keys from the keyboard?

I have the Menu key very close to the Ctrl and left-arrow keys.

xmodmap -e 'keycode 135 = 0x0000' 

To get a first impression what keycodes are mapped to which keys, just type:

xmodmap -pke

which gives you a list of all mappings. For example, the line

keycode  57 = n N

means that the keycode 57 is mapped to a lowercase "n" if no extra key is pressed, and an uppercase "N" if Shift is held.

Some references to get around with things.

  1. xev will let you identify the keycode for your key of interest.
    Look at its man page, This is a good quick reference too,
    Mediakeys with .Xmodmap HOWTO
  2. ArchWiki has a good description for xmodmap

Example to disable/enable backspace:

# Disable
$ xmodmap -e 'keycode 22 = '

# Enable
$ xmodmap -e 'keycode 22 = BackSpace'

where 22 needs to be replaced by the output of xev while pressing backspace.

Tags:

Keyboard