Handwired Alpha - Some basic keyboard theory
A keyboard is a surprisingly simple little device. The basic operation is as follows:
- The switches are wired together into a matrix of rows and columns.
- The controller sends a signal down each column (or row).
- The controller then checks for a return signal down each row (or column).
- This information determines which key(s) have been pressed.
- The controller then sends the keycode to the host machine.
Simple!
So, to construct a keyboard, one must:
- Solder the switches into a matrix of rows and columns.
- Solder the matrix to the controller.
- Program the firmware of the controller so it understands the key matrix.
- Then stuff everything into a case, grab a beer, and call it a day!
The only slightly tricky bit is the matrix itself.
For reasons that are very nicely explained by this write-up, each switch must be attached to a single diode that ensures that current can only cross the switch in one direction. This arrangement ensures that multiple keys pressed together don’t result in the matrix being misinterpreted by the controller.
The typical arrangement is to introduce a diode which allows current to flow from the column to the row, although either arrangement is workable so long as all diodes are arranged the same way.
The open source community has neatly solved the challenged of keyboard firmware. So long as the controller makes use of a supported Arduino chipset, the open source QMK firmware is an incredibly capable solution. To make use of QMK, you simply configure it to understand the key matrix layout, and the associated GPIO pin assignments on the controller. That information is enough to allow QMK to power the keyboard!