How to Use Windows special keys in Linux

Why are all the new keyboards sold with Win95 keys on them? How about making them do real keyboard functions while in X Window? Here is how.

First you need to find out which key mapping you are using. Usually it will be US, it might also be en_US, ca or else. Locate the file, usually in /usr/X11/lib/X11/xkb and edit it with your favorite editor. For me the file is called /usr/X11/lib/X11/xkb/symbols/ca.

The file lists all the key codes and what they do. The key codes for the Win95 special keys are LWIN, RWIN and MENU. All you need to do is add them to the list, with the functions for them. I decided to map the left

WIN key to "@" and the right WIN key and MENU keys to "{" and "}". Here are the lines I added:

key { [ braceleft ] };
key { [ at ] };
key { [ braceright ] };

By browsing the file you can find all the other symbols and what they do. You can also add multiple functions to a key, by using ALT and SHIFT.

The changes will take effect when you restart X Window. With the XKB extension (you do need to have it

enabled in /etc/XF86Config btw) it's easy to change the mapping of any key.

100 Linux Tips
36