This article is free to read. Creating a lesson uses your daily or stored credits; review the language and settings before starting.
How does a computer keyboard work?
Quick answer
A keyboard is a grid of switches. Pressing a key closes a switch at a unique row and column. A microcontroller scans the grid, detects the closed switch, and sends a scan code to the computer. The computer's operating system maps that code to a character, which appears on screen.
A computer keyboard works by using a grid of electrical switches under the keys; pressing a key closes a specific switch, and a small microcontroller detects which row and column intersect to identify the character. That code is sent to the computer, which translates it into the letter, number or symbol you see on screen.
Step by step
- The keyboard's keys are arranged in a matrix of rows and columns, each key sitting above an electrical switch.
- A microcontroller inside the keyboard rapidly scans the matrix by sending signals through each row.
- When a key is pressed, its switch closes, connecting a specific row to a specific column.
- The microcontroller detects the closed switch and determines the key's position in the matrix.
- It sends a unique scan code for that key to the computer through a cable or wireless connection.
- The computer's operating system receives the scan code and translates it into the corresponding character or action.
Key things to understand
- Each key sits above a switch that completes an electrical circuit when pressed.
- The switches are wired in a matrix of rows and columns to reduce the number of wires needed.
- A microcontroller scans the matrix rapidly, checking each row and column for a closed switch.
- When a switch closes, the controller calculates the exact row and column intersection to identify the key.
- The controller sends a unique scan code to the computer, which maps it to the correct character.
Labelled diagram
- Key press
Finger pushes key down, closing the switch beneath it.
- Matrix scan
Microcontroller checks rows and columns to find the closed switch.
- Scan code
Controller generates a unique number for the pressed key.
- Transmission
Scan code travels via cable or wireless signal to the computer.
- OS mapping
Operating system converts scan code into a character on screen.
Real-world examples
- In a laptop, scissor switches under each key provide a low-profile feel while still using a matrix scan.
- Mechanical keyboards like those from Cherry use individual switches with metal contacts that produce a tactile click.
- A USB keyboard sends scan codes to a PC, which the operating system converts into letters in a word processor.
- Wireless keyboards use Bluetooth or a USB receiver to transmit scan codes to the computer without a physical cable.
Common mistake
✗ Myth: Each key sends a unique electrical signal directly to the computer.
✓ Fact: Keys are wired in a shared matrix, and the keyboard's microcontroller identifies which key is pressed by scanning rows and columns. It then sends a scan code, not a direct character signal.
People also ask
How does a keyboard send signals to a computer?
What is inside a computer keyboard?
Why do keyboards have a matrix layout?
Why do some keyboards feel different when you type?
How does the keyboard know which key is pressed if many keys share wires?
What is a scan code?
Can a keyboard work without a driver?
Part of the guide: Everyday Machines →

