Computer keyboard
Control processor

Computer keyboards include control circuitry to convert key presses into key codes (usually scancodes) that the computer's electronics can understand. The key switches are connected via the printed circuit board in an electrical X-Y matrix where a voltage is provided sequentially to the Y lines and, when a key is depressed, detected sequentially by scanning the X lines.

The first computer keyboards were for mainframe computer data terminals and used discrete electronic parts. The first keyboard microprocessor was introduced in 1972 by General Instruments, but keyboards have been using the single-chip 8048 microcontroller variant since it became available in 1978. The keyboard switch matrix is wired to its inputs, it converts the keystrokes to key codes, and, for a detached keyboard, sends the codes down a serial cable (the keyboard cord) to the main processor on the computer motherboard. This serial keyboard cable communication is only bi-directional to the extent that the computer's electronics controls the illumination of the caps lock, num lock and scroll lock lights.

One test for whether the computer has crashed is pressing the caps lock key. The keyboard sends the key code to the keyboard driver running in the main computer; if the main computer is operating, it commands the light to turn on. All the other indicator lights work in a similar way. The keyboard driver also tracks the Shift, alt and control state of the keyboard.

Some lower-quality keyboards have multiple or false key entries due to inadequate electrical designs. These are caused by inadequate keyswitch "debouncing" or inadequate keyswitch matrix layout that don't allow multiple keys to be depressed at the same time, both circumstances which are explained below:

When pressing a keyboard key, the key contacts may "bounce" against each other for several milliseconds before they settle into firm contact. When released, they bounce some more until they revert to the uncontacted state. If the computer were watching for each pulse, it would see many keystrokes for what the user thought was just one. To resolve this problem, the processor in a keyboard (or computer) " debounces " the keystrokes, by aggregating them across time to produce one "confirmed" keystroke.

Some low-quality keyboards also suffer problems with rollover (that is, when multiple keys pressed at the same time, or when keys are pressed so fast that multiple keys are down within the same milliseconds). Early "solid-state" keyswitch keyboards did not have this problem because the keyswitches are electrically isolated from each other, and early "direct-contact" keyswitch keyboards avoided this problem by having isolation diodes for every keyswitch. These early keyboards had "n-key" rollover, which means any number of keys can be depressed and the keyboard will still recognize the next key depressed. But when three keys are pressed (electrically closed) at the same time in a "direct contact" keyswitch matrix that doesn't have isolation diodes, the keyboard electronics can see a fourth "phantom" key which is the intersection of the X and Y lines of the three keys. Some types of keyboard circuitry will register a maximum number of keys at one time. "Three-key" rollover, also called "phantom key blocking" or "phantom key lockout", will only register three keys and ignore all others until one of the three keys is lifted. This is undesirable, especially for fast typing (hitting new keys before the fingers can release previous keys), and games (designed for multiple key presses).

As direct-contact membrane keyboards became popular, the available rollover of keys was optimized by analyzing the most common key sequences and placing these keys so that they do not potentially produce phantom keys in the electrical key matrix (for example, simply placing three or four keys that might be depressed simultaneously on the same X or same Y line, so that a phantom key intersection/short cannot happen), so that blocking a third key usually isn't a problem. But lower-quality keyboard designs and unknowledgeable engineers may not know these tricks, and it can still be a problem in games due to wildly different or configurable layouts in different games.
startend:quotation, change_case:capital_word_frequency[5]