|
|
Using the X Window System > Chapter 9 Customizing the Mouse and KeyboardCustomizing Keyboard Input |
|
Besides remapping the mouse's pointer and buttons to your keyboard, you can remap any key on the keyboard to any other key. To change the meaning of a particular key for a particular X11 session, or to initialize the X server with a completely different set of key mappings, use the xmodmap client. The syntax for xmodmap is as follows:
where options are:
Whether you remap a single key "on the fly" with a command-line entry or install an entire new keyboard map file, you must use valid expressions in your specification, one expression for each remapping. A valid expression is any one of the following: Table 9-10 Valid `xmodmap' Expressions.
The following are the modifier names available for use in keyboard customization:
On Hewlett-Packard keyboards, the lock modifier is set to the Caps key. However, any of the modifiers can be associated with any valid key symbol. Additionally, you can associate more than one key symbol with a modifier (such as Lock = Shift_R and Shift_L), and you can associate more than one modifier with a key symbol (for example, Control = Caps_Lock and Lock = Caps_Lock). For example, on a PC-style keyboard, you can press d to print a lower case "d", Shift d to print a capital "D", Alt d to print something else, and Shift Alt d to print still something else. The xmodmap client gives you the power to change the meaning of any key at any time or to install a whole new key map for your keyboard. Suppose you frequently press the Caps key at the most inopportune moments. You could remove the Caps lock key from the lock modifier, swap it for the f1 key, then map the f1 key to the lock modifier. Do this is by creating a little swapper file that contains the following lines:
Note the use of the ! in the file to start a comment line. To put your "swapper" file into effect, enter the following on the command line:
If you use such a swapper file, you should probably have an unswapper file. The following file enables you to swap back to the original keyboard mapping without having to exit X11:
Note the use of the hexadecimal values to reinitialize the keycodes to the proper key symbols. You put your "unswapper" file into effect by entering the following command line:
On a larger scale, you can change your current keyboard to a Dvorak keyboard by creating a file with the appropriate keyboard mappings.
The -pk option prints a list of the key mappings for the current keyboard.
The list contains the keycode and up to four 2-part columns. The first column contains unmodified key values, the second column contains shifted key values, the third column contains meta (Extend char) key values, and the fourth column contains shifted meta key values. Each column is in two parts: hexadecimal key symbol value, and key symbol name. |
|