Keyboard
A keyboard is an input device made of an array of keys that converts each press and release into an electrical signal a computer can interpret, letting a person enter text, numbers and commands. Its layout descends directly from the mechanical typewriter, and its electronics are a small, self-contained computer: a microcontroller that watches the keys, decides which have changed state, and reports the changes to the host over USB, Bluetooth or an older connector. The keyboard is among the oldest and most durable ways to talk to a machine, and it remains the fastest general-purpose method for entering text and code.
The QWERTY arrangement comes from the typewriter of Christopher Latham Sholes, whose patents of the late 1860s led to the Sholes and Glidden typewriter marketed by Remington from 1873. Early typewriters used typebars that swung up to strike the page, and the usual account holds that Sholes rearranged letters so that frequently paired letters sat apart and their bars were less likely to jam. This explanation is common but disputed by historians, and the popular retelling that QWERTY was designed to slow typists down is a misconception rather than established fact. What is certain is that the layout stuck: typists trained on it, manufacturers standardized on it, and it carried over unchanged to teleprinters and computer terminals. Alternatives exist, most famously the Dvorak layout patented by August Dvorak and William Dealey in 1936, which places the most common English letters on the home row; despite claims of higher speed, the benefit is modest and the cost of retraining has kept QWERTY dominant, along with regional variants such as AZERTY and QWERTZ.
Inside the keyboard, keys are wired as a matrix of rows and columns rather than as one wire per key, and a microcontroller scans the grid many times per second. A full-size keyboard has over a hundred keys, and giving each its own pin would need an impractical number of connections, so the keys are laid out at the crossings of row and column lines. The controller drives one row at a time and reads the columns to see which switches complete a circuit, which identifies every pressed key using only about two dozen pins. The design has a known flaw called ghosting: when several keys are held, some combinations make the circuit look as if an unpressed key were down, which is why cheap keyboards ignore certain chords. Gaming and enthusiast boards add a diode at each switch to block the stray current paths, achieving what is advertised as N-key rollover. The switch itself may be a rubber dome under a membrane, a scissor mechanism common on laptops, or an individual mechanical switch with a spring, such as the Cherry MX family.
The central idea of keyboard software is that a keyboard reports which key moved, not which character was typed. The values produced by the scan are scan codes: the original IBM PC of 1981 used one numbering scheme, later machines used others, and each key sends a distinct code on press (a make code) and another on release (a break code). Modern keyboards speak the USB Human Interface Device standard, in which each key has a usage code in a published table. The operating system maps these positions through the active keyboard layout and modifier state to produce characters, which is why switching the layout to Dvorak in software changes what the same hardware types, and why input method editors can turn several keystrokes into a single Chinese or Japanese character. Games, by contrast, often read raw key positions so that the movement keys sit in the same place on every layout.
Practical points follow from these mechanics, and several common beliefs are wrong. Typing speed is limited by the typist, not by the scan rate, since scanning is done in the order of a thousand times per second, and a wired USB board is not inherently slower than a wireless one by an amount a person can perceive. Pressing a key does not send an ASCII character, which is why a keyboard works identically whatever the language. Keyboards are also a security boundary: keyloggers capture the stream of keystrokes, and a rogue USB device can pretend to be a keyboard to type commands, the reason locked-down machines restrict which USB devices they accept. For programmers, ergonomics matter, and split, ortholinear and programmable keyboards running open firmware such as QMK let users remap every key, treating the keyboard as the small programmable computer it already is.
Read a keyboard as a grid of switches wired to a tiny scanning computer that reports positions, with the operating system translating those positions into letters, which explains why a nineteenth-century layout still works on any modern machine and why changing a layout never requires changing the hardware.