Rows and columns, checked constantly
How Does a Keyboard Know Which Key You Pressed?
There is no wire from every key. There is a grid, and the keyboard reads it hundreds of times a second.
-
Step 1 of 5
One wire per key would be a lot of wire.
A hundred keys would need a hundred wires running to the chip, plus a shared return. Cheap keyboards do not have room for that and do not need it.
-
Step 2 of 5
So the keys sit on a grid of rows and columns.
Each key is a switch at one crossing. Pressing it joins that row to that column, and nothing else in the keyboard changes.
-
Step 3 of 5
The chip finds it by asking one row at a time.
It energises row one and reads every column, then row two, and so on. Whichever column answers tells it exactly which key is down.
-
Step 4 of 5
It goes round that loop hundreds of times a second.
Fast enough that typing feels instant, and fast enough to notice a key going down and coming up as separate events — which is how holding a key works.
-
Step 5 of 5
A key contact does not close cleanly, so the chip ignores the first millisecond.
The metal bounces as it lands, making several brief contacts. The chip waits for the bouncing to settle before deciding — otherwise one press would type five letters.
QWERTY was laid out for mechanical typewriters, whose bars jammed when neighbouring letters were struck in quick succession. Nothing since has been worth the retraining.
The short version
A keyboard wires its keys as a grid and scans row by row hundreds of times a second, so twenty wires can tell which of a hundred keys is down.
Try it yourself
Hold three or four keys at once in a text box. Some combinations refuse to register, because those keys share a row and a column and the grid cannot tell them apart.