digiot, I thank you for the reply above. I was in fact using elvis, however since that time I have changed it over vim.
I have finally got around to figuring this out, so I am writing how I did it on my system in case anyone is interested, or if there is a search for this subject the answer will be here.
The keys I want to remap are the two keys on the bottom of the keyboard that have the windows flag on them. On the left side it is between the ctrl and alt keys, on the right it is next to the alt key. In windows this key will pop up the start menu, I don't use windows, so I am finding another use for them.
Below is how I did it for my system. If you want to try this do so at your own risk, I could see it being really easy to whip out your keyboard doing some of this stuff, so make the backup files. My system is as follows:
linux 2.4.22 kernel
X-Windows, using gnome 2.4
using default keymap (this is very important, you must edit the keymap you use).
First I discovered that the console, say under ctrl+alt+F2, uses a different keyboard map than the X system. To change the mapping for the console this was the process:
First I needed to know what the number of the keys were what I wanted to change. To do this I switch over to another console and did the command:
then when you type a key it will show you the numbers.
For my system the esc key is number 1 and the two windows keys were 125 and 126.
The showkey command does not work well under an Xterm. When I did it using an Xterm I had to kill the process, it won't shut itself down.
Then, I ran the loadkeys -d command to find out what was the default keymap for my system. This returned the following directory:
I cd'd into that directory and made a copy of the file, the second is a backup, I usually just
add .backup to the end of the file name, i.e., defkeymap.map.gz.backup.
Then I unzipped the file:
which gave the unzipped file:
I opened up the file in vi and copied everything under number 1 and pasted it under the numbers 125 and 126. Here is the example of my file for these numbers:
keycode 1 = Escape Escape
alt keycode 1 = Meta_Escape
keycode 125 = Escape Escape
alt keycode 125 = Meta_Escape
keycode 126 = Escape Escape
alt keycode 126 = Meta_Escape
In the area that says 1= Meta_Escape, you do need to change the 1 to 125 and 126 like it is listed here.
Once that was done, I just saved the file, re-zipped it with
Then I ran the loadkeys -d command again, and in the console, I then could use either one of the win keys as an escape.
The X-term has a little bit more involved. For this I started a X-term session, then ran the command :
This pop's up a little window, and gives an enormous about information. I click in the window to make sure it was the window that was receiving the commands, then I would hit the keys I wanted to change, in this case the esc key, and the two windows keys. The output to this looked like:
KeyPress event, serial 25, synthetic NO, window 0x1e00001,
root 0x3a, subw 0x0, time 29429511, (175,175), root
state 0x10, keycode 9 (keysym 0xff1b
, Escape), same_screen YES,
XLookupString gives 1 bytes: ""
This gives the keycode number I was looking for, and the keysym number. I needed to write down the keycode number of all three keys, and the keysym number of the esc key.
Then in my home directory, I create a file called .xmodmaprc and put in the following information.
keycode 115 = 0xff1b
keycode 116 = 0xff1b
That is the total contents of the file. The keycode's are the code's for both windows buttons, and the 0xff1b value is the keysym value obtained from the xev command.
I then saved this file, and set the execute permissions.
Then I ran xmodmap ./.xmodmoprc, and then the two windows keys worked as escape keys. I put the line:
xmodmap .xmodmaprc in my .bashrc file, so every time I log in it should run it.
The man page for xmodmap is really detailed, and would be great place to get questions answered.
*Note: I am not the best with terminology, If I have put something confusing in here let me know, I will happily change it.