Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.