Caps Lock is in my opinion one of the most useless keys on a keyboard. Unless you own one of those keyboards specifically designed for Linux, your keyboard most likely has a Caps Lock key located in a prime real estate area: right above the Shift key.
How do we remap the Caps Lock key to something more useful, say the Esc key? Why the Esc key? See my earlier article.
First, specify the new key mapping in the file ~/.Xmodmap:
$ cat >> ~/.Xmodmap
remove Lock = Caps_Lock
keysym Caps_Lock = Escape
Note that the file ~/.Xmodmap may not pre-exist in your distro. The above command will create the file.
Next, execute those new mappings by:
$ xmodmap ~/.Xmodmap
Test it out by opening a command window in X. Type in some words on the command line. Press the new Esc key(formerly Caps Lock), and then the key b. This should move the cursor back a word.
The above will do the key remapping for your X-Window environment. The key mapping is not changed for your console windows. We will save that topic for another day.