Q: How can I disable one or several keys on my laptop keyboard in Linux? When I press the DELETE key, it gets stuck and deletes everything 🙂
A: No problem! You can use the following command to remap or disable any key of your keyboard:
xmodmap -e 'keycode <value>=<action>'
For example, you could run the following command to disable your DELETE key:
xmodmap -e 'keycode 107='
How to get the correct keycode
You can get the keycode that corresponds to a specific keyboard button in one of two ways.
The first method is by using the simple command xev. xev opens a window and then monitors “events” such as keystrokes. It is suitable when you are running a GUI.
The second method, which can be run with only the console, is showkey. This command will monitor for keystrokes for 10 seconds, or until a SIGTERM signal is received.
List of all keycodes
The full list of available keycodes and actions assigned to them on UK keyboard is below…