I got my first mechanical keyboard 1 and a half years ago. I got me
a 60% Vortex Pok3r III with LED backlighting and MX-Clear switches.
All in all it is a nice keyboard, I used it happily. However the
customisation it offers is both a blessing and a curse. The good
thing about it is, that it requires no flashing tool and can be done
on the fly by typing keys on the board using a special programming
mode. The bad thing about it is, that there is no tool to read this
customisations back out for backup. So when you have to reset the
keyboard which happened 3 times to me you loose all your nifty
customisations.
So I did some research about building your own mechanical keyboard
and it has been a wild ride ever since. It turns out making your own
keyboard is pretty easy. And there is even a wide variety of open
source designs available to choose from.
* Keyswitches
* A plate
* A case
* A controller / A PCB
* Some LEDs / diodes
* Keycaps
Keyboard switches come in two basic "shapes" which refers to their
footprint on the PCB / plate: Cherry style switches (MX) or Alps.
MX-Switches are by far the most commonly used ones when it comes to
keycaps. I haven't tried alps yet, so I cannot tell you anything
about them. Another (rather expensive) outlier are TOPRE switches
which is an advanced topic if you want to build a board yourself.
Another parameter for switches are the forces need to activate the
switch and whether there is a tactile or audible actuation point. To
distinguish them the switches are referred to by color.
- Linears: Red, Black - Tactile: Brown, Clears - Clicky: Blues
So far I have tried blues, reds, clears and browns. Blacks are on a
prototype. Also note that Cherry clones may have different color
codings, such as Gateron or Zealios switches. To get a feeling for
the switch types either try them on a keyboard from a friend or a
shop or get a keyswitch tester, which is a 4x4 numpad like case that
includes several different types of switches. If you have decided on
a switch type, decide on the case.
You got a couple of options:
- CNC'ed cases, those are hard to make youself unless you have access
to a CNC Mill. Those are around 50->100 EUR or more depending on
the type and material.
- 3D Printed cases: Those are rather cheap in comparison. Some models
like the crazy dactyl keyboard can only be made with 3D printed
parts.
- Sandwhich cases: Either made from steel with standoffs or wood /
acrylic layers or a combination thereof. That may be the cheapest
option if you have access to a laser cutter.
So you see, a local fablab is key to keeping the price tag down to a
minimum :)
The innards of the keyboard consists of the switches being connected
through some diodes to a microcontroller. The diodes are there to
prevent ghosting effects. The microcontroller used on mosed boards
is a cheap and easily available Atmega32U4, which contains a USB
controller that will do the communication for us. If you want a
wireless board there are bluetooth enabled Atmega boards that can do
the comms for you.
If you don't want to wire the keyboard matrix yourself you can get a
PCB. There are quite a few open source designs for PCBs out there
that require you to solder on the switches, diodes and a cheap
controller (Atmega32U4 in one of its dev board variants). Or you buy
presoldered PCBs as a kit.
I did hand-wire most of my built boards, it turns out that it is easy
to do, it is easy to debug and easy to fix. A PCB approach on the
other hand means that you can save some height on you building, since
you don't need as much space below the plate. Also the PCB acts as a
stabilizer so it might be a sturdier build.
Thanks to technomancy's Atreus hand-wiring guide I tried to hand wire
my boards. The Atreus is also the first board that I built and it is
still one of my favourite daily drivers.
As for the controllers used there are a wide range of arduino pro
micro clones out there, most of them featuring a usb micro connector.
I have seen a clone with usb mini connectors as well! Or you can get
the Teensy which is of better quality but also twice the price of an
arduino clone.
Electronically a keyboard is a simple circuit consisting of a lot of
switches and a microcontroller. The microcontroller checks which of
the switches are pressed and generates a scancode for the operating
system. This scancode is then translated to a key event depending on
the selected layout of the OS.
Now since a microcontroller does not have one input pin for each
individual key, the keys are wired as a so called matrix. In the
matrix keys are arranged in columns and rows. Each row and each
column is wired together and connected to one pin. Maybe it helps if
you imagine the matrix as a coordinate grid, with the rows and cols
on the axis. The microprocessor then checks periodically where on
the matrix a circuit is closed (the key switch is pressed). That way
a single compination of row/col pins can identify the exact key that
has been pressed.
Now as electricity is a funny thing the effect of ghosting may be a
problem when certain combinations of keys are pressed in the matrix.
For a better explanation see here[]. To prevent this diodes are
soldered in either rowwise or columnwise. The firmware on the
controller needs to know this to scan the pins in the right
direction.
That's all there is to it! The rest of the magic happens in a big
state machine on the microcontroller.
For the cases you need 2D/3D design tooling. I used FLOSS, which
leaves me to: OpenSCAD, FreeCAD, Inkscape and VisiCut.
For the sandwhich case you can download a lot of cases as SVGs which
you can use to feed to VisiCut for cutting on your fablab's laser
cutter. For a orthogonal planck build I used OpenSCAD to model the
SVG files and I like the procedural approach for that.
For 3D-printed cases you can either use OpenSCAD or FreeCAD to design
your case or use a STL file off of thingiverse.
For the firmware you can use the QMK keyboard firmware which has the
most features implemented, including speaker support or a midi
keyboard, and also features a lot of predefined layouts and board
types. But there are also a lot of other firmwares available, or you
can build your own matrix scan software.
To flash and build the software you need a gcc-avr toolchain and
avrdude / dfu-programmer depending on the bootloader of your
controller.
And of course you need a multimeter, a soldering iron, wires, a flush
cutter, a self adjusting wire stripper and a multimeter for debugging
your soldering joints.
One of the tricks I have learned for hand wiring is that you make a
little loop with the wires around the pins before soldering them on.
That will result in a secure physical connection and you won't be
able to rip off the wire again (well normally anyway).
Also designing a case is non-trivial if you want some extras. While
it looks shiny in OpenSCAD, the laser cutter adds kerf, the arduino
clonse may come with different headers, sizes, pcb thickness...
Acrylic tends to snap easily.
So what I want to tell you probably is: Expect to fail, expect to be
non perfect, there are things that will go wrong in your build and
that's the chance to learn something. Still works for me and it is a
humbling experience. Also expect to fix broken stuff, even act as if
the newly built thing will break as soon as you finish! Then when
things break I can tell myself "oh, sure, of course it breaks, let's
see whether I can fix it".
If you get annoyed at some failure, back off, do something different,
have a break. Then think about your options.
I guess this is all a good general approach to things but during this
activity with physical things (which I don't do often enough) this
all became clearer to me.