Tech Behind ThingsHow the ordinary machinery actually works

Devices

What Actually Happens When You Press A Key

A keystroke is not a simple switch closure, because the contact bounces, the keyboard scans a grid rather than each key, and both facts shape how typing feels.

A classroom setting featuring laptops and desks, capturing a modern educational environment.
Photograph by Adam Sondel via Pexels
Editorial note. Independent reporting and analysis. Nothing here is sponsored or paid for. How we work.

Pressing a key looks like closing a circuit, and in principle it is. The complications between that closure and a character appearing explain most of what distinguishes one keyboard from another.

Keys are wired as a grid

A keyboard with a hundred keys does not have a hundred wires running to its controller. The keys sit at intersections of a matrix of rows and columns.

The controller energises one row at a time and checks which columns respond. A key is identified by which row and column were active together.

This reduces the wiring dramatically, but it introduces ambiguity. Certain combinations of three pressed keys produce a fourth apparent press, because the electrical path cannot distinguish them.

Diodes fix the ambiguity, at a cost

Placing a diode at every intersection forces current to flow one way and removes the phantom readings. Any number of keys can then be pressed simultaneously and reported correctly.

This is what is being sold as full rollover, and it matters mainly for gaming and fast typing where several keys overlap in time.

Cheaper keyboards omit the diodes and instead arrange the matrix so that the combinations most likely to conflict are unlikely in practice. It works until it does not.

The contact bounces before it settles

A mechanical contact does not close cleanly. The metal springs against itself for a short interval, opening and closing several times within a few milliseconds.

Read literally, that single press would register as several. Firmware therefore ignores further changes on a key for a short window after the first one.

That window is a compromise. Too short and keys repeat themselves, too long and rapid deliberate presses get discarded, which users describe as the keyboard missing input.

Switch type decides the feel, not the signal

Membrane, scissor and mechanical switches all end up reporting the same event. What differs is the force curve, the travel distance and where in that travel the contact occurs.

A switch that registers early lets a fast typist move on before bottoming out. One that registers near the end gives a clearer sense of completion.

Some designs replace the contact entirely, sensing the position of a magnet or an optical beam. These avoid bounce altogether and allow the activation point to be adjusted in software.

The delay is mostly elsewhere

Scanning and debouncing together account for only a few milliseconds. The larger part of perceived typing lag usually comes from the connection and the display.

Wireless links batch reports to save power, and screens refresh at fixed intervals. A character can be known to the system well before there is an opportunity to draw it.

Blaming the keyboard is therefore often wrong. The switch has done its job long before the letter reaches the screen.

Questions readers ask

Why does brightness jump when I unlock the phone?

The sensor is often only sampled while the screen is on, so the first reading after unlocking replaces a stale value from earlier.

Does automatic brightness save battery?

Usually yes, because most people set a fixed level high enough for the worst case and then leave it there in dim rooms.

Devicesdisplayssensorsperceptionpower
Grigor Petrov
Hardware writer, Tech Behind Things

Grigor writes about silicon, thermals and the physical limits designers keep bumping into.

Also by Grigor Petrov