# Why are the keyboard scan codes for digits off by one?

Raymond

In

Off by one what, exactly?
,
my colleague
Michael Kaplan
wrote

And this decision long ago that caused the scan codes to not line up
for these digits when they could have…

The word that struck me there was “decision”.

Because it wasn’t a “decision” to make the scan codes almost-but-not-quite
line up with digits.
It was just a coincidence.

If you look at the scan code table from Michael’s article

you can see stretches of consecutive scan codes,
broken up by weird places where the consecutive pattern is
violated.
The weirdness makes more sense when you look at the original
IBM PC XT keyboard:

 01Esc 021 032 043 054 065 076 087 098 0A9 0B0 0C− 0D= 0E← 0F⇥ 10Q 11W 12E 13R 14T 15Y 16U 17I 18O 19P 1A[ 1B] 1C↲ 1DCtrl 1EA 1FS 20D 21F 22G 23H 24J 25K 26L 27; 28‘ 29` 2A⇧ 2B\ 2CZ 2DX 2EC 2FV 30B 31N 32M 33, 34. 35/ 36⇧ 37* 38Alt 39Space 3ACaps

With this presentation, it becomes clearer how scan codes were assigned:
They simply started at 01 and continued through the keyboard
(Scan code 00 is an error code indicating keyboard buffer overflow.)
The reason for the keyboard scan code being off-by-one from the
digits is merely due to the fact that there was one key to the
left of the digits.
If there were two keys to the left of the digits, they would have
been off by two.

Of course, if the original keyboard designers had

started counting from the lower left corner,
like all right-thinking mathematically-inclined people
,
then this sort-of-coincidence would never have happened.
The scan codes for the digits would have been
2E through 37, and nobody would have thought anything of it.

It’s a testament to the human brain’s

desire to find patterns and determine a reason for them

that what is really just a coincidence
gets interpreted as some sort of conspiracy.