How to disable / re-map keyboard keys in the kernel?

Solution 1:

Neither kernel module nor kernel hack are necessary.

Using setkeycodes you can change the scancode to keycode translation mapping of the running kernel, requiring root privilege of course.

To map Caps Lock (scancode 0x3a) to say the key with the letter x (keycode 45) you would use setkeycodes 3a 45 to give an example.

Using showkey -s and showkey you should be able to find needed scancode and keycode.

Be sure to issue given commands from the console not from a terminal.