Understanding Keyboards in Linux

In order to manage a keyboard in Linux, it helps to understand what happens to keyboard input data. Figure 3.3 illustrates this process. The keyboard sends a scan code to the computer. This code maps to a physical key, but any given scan code might represent a different symbol depending upon the keyboard type. For instance, a Russian keyboard might return more-or-less the same scan codes as a U.S. keyboard, but the Russian keyboard's scan codes map to Cyrillic letters, whereas the U.S. keyboard's scan codes map to Roman letters. This mapping to individual symbols is done in different ways depending upon whether the computer is running in text mode or in X.

Figure 3.3: Keyboard input processing in Linux can take one of two paths.

In text mode, the kernel interprets the scan code and creates a key code. Most text-based Linux programs, though, are designed to work both from the console and from remote logins—dumb terminals, network logins, xterm windows, and so on. Therefore, a terminal driver converts key codes into a final code type that I refer to as a terminal code. This code is a uniform representation of the symbol on the keyboard, no matter what device generated the keypress.

When you run X, the X server reads scan codes directly and does its own conversion into an X-based terminal code. X-based programs work from this terminal code. When you run a text-mode program in an xterm window, the xterm must generate a conventional text-mode terminal code from the X terminal code.

In summary, three major key mapping conversions take place. You can modify any of these mapping operations by running the appropriate utilities or modifying configuration files. When you installed Linux, one of the questions you were asked was what type of keyboard you use. The installation program used your answer to this question to set up appropriate keyboard maps for both text mode and X. You might have cause to adjust this map, though. For instance, you might have given the wrong information when you installed Linux, or the map might be incorrect as delivered by the distribution provider. You might also want to change the map to individualize the keyboard to your liking. The next two sections, "Getting a Keyboard to Work in Text Mode" and "Getting a Keyboard to Work in X," describe how to do this.

0 0

Post a comment