Skip to content
Know.itKnow.it
Create an animated lesson
On request

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?

TechnologyLesson on requestFree to read

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

  1. The keyboard's keys are arranged in a matrix of rows and columns, each key sitting above an electrical switch.
  2. A microcontroller inside the keyboard rapidly scans the matrix by sending signals through each row.
  3. When a key is pressed, its switch closes, connecting a specific row to a specific column.
  4. The microcontroller detects the closed switch and determines the key's position in the matrix.
  5. It sends a unique scan code for that key to the computer through a cable or wireless connection.
  6. The computer's operating system receives the scan code and translates it into the corresponding character or action.

Key things to understand

  1. Each key sits above a switch that completes an electrical circuit when pressed.
  2. The switches are wired in a matrix of rows and columns to reduce the number of wires needed.
  3. A microcontroller scans the matrix rapidly, checking each row and column for a closed switch.
  4. When a switch closes, the controller calculates the exact row and column intersection to identify the key.
  5. The controller sends a unique scan code to the computer, which maps it to the correct character.

Labelled diagram

  1. Key press

    Finger pushes key down, closing the switch beneath it.

  2. Matrix scan

    Microcontroller checks rows and columns to find the closed switch.

  3. Scan code

    Controller generates a unique number for the pressed key.

  4. Transmission

    Scan code travels via cable or wireless signal to the computer.

  5. OS mapping

    Operating system converts scan code into a character on screen.

How a key press becomes a character

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?
The keyboard's microcontroller scans the key matrix and generates a scan code for each key press. It sends these codes through a USB cable, PS/2 cable, or wireless connection. The computer's operating system receives the codes and maps them to characters or actions.
What is inside a computer keyboard?
Inside a keyboard you find a plastic case, keycaps, and a circuit board. Under the keys is a membrane or individual switches arranged in a matrix. A small microcontroller chip scans the matrix and communicates with the computer.
Why do keyboards have a matrix layout?
A matrix layout connects keys in rows and columns, reducing the number of wires needed. Without a matrix, each key would need its own wire to the controller. The matrix allows hundreds of keys to be scanned with far fewer connections.
Why do some keyboards feel different when you type?
Keyboards use different switch types: rubber dome, scissor, or mechanical. Rubber dome keys collapse a rubber dome onto a membrane, giving a soft feel. Mechanical switches use a spring and metal contact, giving a crisper click and longer life. Scissor switches are common in laptops for a low-profile feel.
How does the keyboard know which key is pressed if many keys share wires?
The keys are arranged in a grid of rows and columns. The controller sends a signal down each row and reads the columns. If a column receives the signal, the controller knows the key at that row and column intersection is pressed. This matrix design saves wires and simplifies wiring.
What is a scan code?
A scan code is a number that identifies a specific key, independent of the character it produces. For example, the 'A' key always sends the same scan code. The computer's operating system then translates that scan code into 'a' or 'A' depending on whether Shift is held.
Can a keyboard work without a driver?
Basic keyboards use standard protocols like USB HID, so most operating systems recognise them without extra drivers. The keyboard sends scan codes, and the OS maps them to characters. Special keys like media controls may need drivers or software to work fully.

Part of the guide: Everyday Machines →