Skip to story
ELI5 Yahaaa

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.

About a hundredkeys Wired as a grid, notone wire each
Twenty wires can watch a hundred keys.
  1. Step 1 of 5

    One wire per key would be a lot of wire.

    A wire per key About a hundred wiresA grid Ten rows and tencolumns — twenty

    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.

  2. Step 2 of 5

    So the keys sit on a grid of rows and columns.

    1 A key goesdown2 A row isjoined to acolumn3 One crossing,and only one

    Each key is a switch at one crossing. Pressing it joins that row to that column, and nothing else in the keyboard changes.

  3. Step 3 of 5

    The chip finds it by asking one row at a time.

    Energise a row Read thecolumns Move to thenext row

    It energises row one and reads every column, then row two, and so on. Whichever column answers tells it exactly which key is down.

  4. Step 4 of 5

    It goes round that loop hundreds of times a second.

    How fast you can typeA few keys asecondHow fast it scansHundreds ofscans 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.

  5. Step 5 of 5

    A key contact does not close cleanly, so the chip ignores the first millisecond.

    The contactbounces onlanding Wait a moment,then decide

    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.

Tags