-   Linux - Newbie (
-   -   Remap Caps Lock key to ESC (

MTK358 01-24-2010 01:55 PM

Remap Caps Lock key to ESC
I wanted to remap my Caps Lock key to ESC, both because I don't need the Caps Lock key and because it will make it easier to use vi.

I know how to do this in X, but is there a solution that will work in command line mode too?

White Tea Citrus 01-24-2010 03:50 PM

mapping keys in raw console
I'm sorry for not being more specific, I couldn't test this myself due to no access to a console, I found out however that there might be also /usr/bin/loadkeys in your distro, which works in a similar way to xmodmap.

I suggest trying to update your /etc/rc.local with loadkeys in your local test environment.

MTK358 01-24-2010 04:47 PM

I don't understand.

White Tea Citrus 01-24-2010 08:04 PM


Originally Posted by MTK358 (Post 3839031)
I don't understand.

My fault, what I meant is:
First of all, you need to find the Caps Lock & the Esc key's map. You could find it in x (my suggestion was you know how to do this), or if you can't, type showkey followed by pressing the Caps Lock & the Esc buton, or you can type showkey -h or man showkey as well for some guidance. Now, to set the keymap temporarily, I found out that the keycode app suites the purpose, so you can type:

keycode ""esc key code's map No."" = Caps_Lock
keycode ""esc key code's map No."" = "The Escape button"

Be sure to change them codes back after usage. Now, for a permanent change, there is this loadkeys made into rc.local thing I mentioned, but I don't understand it yet.

MTK358 01-24-2010 08:16 PM

I still don't quite get it, and also I don't want the ESC key to become caps lock. I don't want any caps lock key whatsoever.

White Tea Citrus 01-24-2010 08:30 PM

For getting it there is man.

man man

hda7 06-03-2010 03:52 PM

Basically, there are some keymap files (to find them try "find / -name") that specify what keys do what. Each key is identified by a number (I think Caps Lock is 58) and each line specifies the mapping between the key numbers and their use. A line like "keycode 58 = Escape" should do what you want. I would copy to another file, and edit the "keycode 58" line as specified. Then run "loadkeys <updated file>". see man keymaps, man loadkeys, man showkey, and man dumpkeys. (I just did this myself about five minutes ago.)

All times are GMT -5. The time now is 09:39 AM.