Why are the keyboard scan codes for digits off by one?
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:
With this presentation, it becomes clearer how scan codes were assigned: They simply started at 01 and continued through the keyboard in English reading order. (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.