A project log for The Smallest Keyboard

v1 USB keyboard approximately the size of three pennies in a line; v2 around the size of a quarter

tecistTEC.IST 12/16/2021 at 01:020 Comments

I received feedback on the Threadripper Laptop video that some would have liked to see a build video along the way.  Well, here goes for the next project.  The first component I'm nailing down is a very small keyboard, around the size of three pennies in a row.

There are BlackBerry keyboard-to-USB kits out there, though they require adapters and don't give you the full range of keys you might use with a PC.

There are small(-ish) key matrix decoder keyboards out there as well, though the tactile switches tend to be larger and spaced further apart.

What I settled on was a 59-key keyboard in the footprint of the Raspberry Pi Pico, with the microcontroller handling the key matrix decoding and USB interface.

The keyboard has a standard QWERTY layout with a full number row, symbol keys typical of a PC keyboard, Escape, CTRL, ALT, Shift, Backspace, Enter, Space, and directional arrows.

To fit it all in I found a very small tactile switch, the B3U-1000P, measuring just 3.0 x 2.5 x 1.6 mm. Making key matrix connections by hand in such a tight space would be miserable, so a PCB was the way to go.  I went with JLCPCB because Easy EDA (their online PCB design tool) is, well, easy.  There are top and bottom traces, as the matrix needs to crisscross.

The matrix is decoded by two nested loops: one through rows and one through columns.  Each key has it's own unique row and column combination.  The microcontroller loops through each possible combination and returns the value corresponding to the key pressed.

One potential downside to this approach is ambiguity when multiple keys are pressed at the same time, i.e. which key am I intending to hit and in which order.  Some keyboard circuits use diodes to prevent this, but these are omitted here due to space considerations and because the ergonomics of this particular keyboard having to be carefully pressed often by fingernail, it is unlikely to run into multiple keys being pressed at the same time.  Exceptions are any keys that can modify the meaning of another: CTRL, ALT, and Shift can all be read independently to see if the key being pressed is being modified in any way by these keys.

I originally named the keys according to their content, including special characters, so helpful labels would print on the PCB, but JLCPCB's systems ended up not playing nicely and left two switches out of the pick and place arrangement.  I modified these names to remove the special characters that caused problems before uploading the project files.

Small batch PCB cost is around $10 per board, not awful considering there are 59 placed components and several large pads for direct soldering to a Raspberry Pi Pico (the black PCB and lead free options were nice as well).  Adding the cost of a Pico and economy shipping, this can be replicated for around $20 per unit in batches of 5+ units.

Project files including the PCB and pick and place file are linked in the description.

In the second installment, we'll write the key matrix decoder.