Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to remap my Caps Lock key to either nothing or a key code of my choice.

To get the same behaviour across different environments (X / Wayland / non-graphical TTYs), and for learning how to do things like that, it is important to do it at the kernel level (so xmodmap/xkb solutions will not help me).

How would I go about that?

Also, will a kernel module be sufficient or will it need to be a direct code change?

Thanks for any hints!

share|improve this question

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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .