Designing and Building My Own Keyboard
June 5, 2015 • 5 minute read
Disclaimer: This post is a retrospective. I originally wrote about this on thomasmoll.co, which is now defunct.
I started this project after my sophomore year of college at Iowa State University. I was a few weeks in to my second internship at Garmin on the Automotive OEM team and I was getting more and more into mechanical keyboards. I had seen some people designing and building their own from scratch, so I decided to try my hand at it. Unfortunately I’m typing this on a Pok3r, a keyboard which is much, much better than the one I made.
I knew I wanted a 60% keyboard, a type of keyboard which lacks the navigation arrows and number pad. Instead of moving your hand from one section of the keyboard to another, you simply use macros to “shift” into a different mode. For instance, right now I have the
CAPS LOCK key mapped as my meta key, holding it turns the keys
L into the arrow keys Up, Left, Down and Right respectively. Perfect for long days at a terminal when you don’t want to be constantly readjusting your fingers. I’m a touch typer, meaning I don’t look at the keyboard when I’m typing / programming. It also means you have less distance to move your arm when using the mouse again.
The first step to any hardware gadget design: what the hell is going to hold all my electronics? For typical keyboards they’ll have a plastic or metal clam shell which encapsulates a PCB (printed circuit board) which has either mechanical switches or rubber domes layered on top. Then the keycaps fit onto the plastic stems on the switches.
For my keyboard I went with a basic top plate to hold the switches, and a bottom plate to keep it all in place. I found a neat website to auto-generate CAD layouts called swillkb. That summer I was fortunate enough to have a family friend named Gary who does consulting work as a master machinist in retirement. In his garage he has a Personal CNC, Rotary Lathe, 3d Printer and all the tools you could ask for. I told him about the job I wanted to do and he helped me setup the toolpath, walked me through how to setup my work piece, select an endmill and kept tabs on the machine for any chattering.
I can’t thank Gary enough, he took a Saturday to mentor me and pass down some really important skills I wish I used more often. We were able to mill the front and back plates with relative ease, after all I had a master mechanical engineer looking over my shoulder. In hindsight, this is really a better task for a plasma cutter or even better a water jet cutter. The CNC machine uses rotary bits to cut away material, and we had to use three different passes with smaller and smaller bits to carve out the corners. Typically you’d use an 1/4th inch bit, then a 1/8th inch and so on until the work piece was finished.
On to the next step, hand wiring. Since I didn’t feel like getting into PCB production for this build, I decided to hand wire each row. The electrical layout uses 5 rows and around 14 columns to make a 2d matrix of possible key presses. The microcontroller sends a pulse out on each row, detecting which column connects the circuit. It does so with a relatively simple diode setup, preventing current from flowing backwards.
I originally live streamed this on Twitch.TV, fortunately for me, some viewers pointed out that I was soldering the plate backwards, meaning I had to desolder the entire thing and flip the switches to the opposite side… Anyways, 6 hours later I had the thing soldered up to my microcontroller of choice, the Teensy. Had this been in 2018, I could have soldered a Raspberry PI Zero W to it and had a portable linux computer, it’s really amazing how times change.
Programming was done via TMC, fortunately configuration is relatively simple, debugging is a bit hard, since you’re testing the hardware AND software together. I had a few keys stuck on, making it hard to test on the same computer you’re programming on when your rogue keyboard is typing “ggggggggggg” 20 times a second.
TMK makes keymaps easy with a GIANT macro:
Due to the bespoke design, troubleshooting was easy, yet fixing involved desoldering and unwinding a beautiful spiderweb of signal wire.
After a few hours and a few soldering iron burns later, my keyboard was in a working state.
I actually did end up using the keyboard, unfortunately due to some shift key problems, it was never my daily driver. For a first attempt, I think it turned out pretty good! The project overall was a vehicle to learn something new and build on my Computer Engineering skills from school.⧠