Transferred from the blog http://wilt.isaac.su/articles/how-to-remap-your-capslock-key-to-esc-key-in-ubuntu-linux
There are many methods on the network, but I have basically tried them all. There are too many unreliable ones, especially many blogs, and you may just post them without trying them yourself. So sometimes it is recommended that you still search in English, so that maybe the answer will come out soon.
Modifications for other systems:
Mac http://lovekaiyuan.iteye.com/blog/2276270
Windows http://lovekaiyuan.iteye.com/blog/2276224
# The first step is to create a file .Xmodmap in your home directory vim ~/.Xmodmap # add the following !! No Caps Lock clear lock !! Make Caps_lock an escape key. keycode 0x42 = Escape # The second step is to execute the following command xmodmap ~/.Xmodmap Done, you can test it. If you add a usb keyboard, you need to re-execute the command in the second step, so that the system can get the keyboard again.