How to build ANY keyboard? - Concept to reality
So you have a visual of your ultimate keyboard layout. How do you turn it into reality? In this article you will find a general guide to build a keyboard along with the most used tools and resources as of 2021.
The best thing? All the tools are free!
I offer you three pathways. This guide covers the basic method intended for absolute beginners. With this approach you can quickly create ortholinear and classic staggered keyboards. If you run into limitations (e.g. with split or angled layouts) check the (upcoming) intermediate or advanced workflows.
This workflow will include KLE, plate builder, Inkscape, QMK. All free and most even open source.
Concept
So you have this great idea but you are stuck with a pencil sketch on a piece of paper. Now what? How to turn this into an actual artwork or slab of steel ready for some abuse?
If you have to ask this question chances are you aren't familiar with CAD, PCB design, electronics or manufacturing at all. Never mind. This guide is for you.
#pic-sketch
Professionals may use expensive software and advanced techniques to design and mass produce keyboards. However, you don't need these to build a single keyboard. In this write-up we will focus on popular and easy-to-use free tools available for everyone.
Let's dive right in!
Plate design
Starting with designing the plate will be our first step. The plate is where you put your switches in. Many designs don't have an actual case (sandwich case or bottomless build), thus, the plate is the only part holding the keys and keyboard together.
How to design a plate? The most flexible and sophisticated method would be to draw the outline and the cutouts of the plate in the graphics software of your choice (e.g. Inkscape, Adobe Illustrator, CorelDraw). Unfortunately, this is the most difficult method.
If you are familiar with vectors, I give you all the necessary measures to go berserk in the (upcoming) intermediate guide.
Assuming you have no experince in vector drawing, let me introduce our first free tool: the Keyboard Layout Editor or KLE.
Let's start with "drawing" the keyboard in KLE. As you will see, it's not really drawing but rather like working with LEGO bricks: KLE uses the single-with key as its basic unit (1u).
Open KLE in your browser and depending on your concept load a preset or start creating the layout from scratch.
If your design is anything similar to an existing layout you can choose a preset and start by simply altering it. KLE plate design guide.)–>
In case you came up with something really unique, KLE makes it easy to put a layout together from scratch too.
In this example we draw an ortho board with 4-4 macro keys on both sides and a little gap between the two halves.
Start with a blank canvas, add some keys, feel free to copy&paste groups of them to boost your productivity. Also, focus on the physical layout only. Keycap profiles, labels, colors are irrelevant in relation to the plate design.
KLE is great for most ortholinear and classic staggered layouts. The only area it really lacks important features is the world of angled and split keyboards. In case you are working on such a split keyboard, check the alternative workflow presented in the (upcoming) intermediate plate building guide.
Generating a DXF file
To lasercut a plate you will need a DXF file. Don't panic. The DXF, originally an AutoCAD format, is a simple, humble vector file (just like SVG) only with exact measurements to allow precise manufacturing.
There are free tools to generate a DXF file. Copy the KLE raw data of your layout (raw data tab) into one of the popular plate builders, e.g.: https://kbplate.ai03.com/.
In most cases you don't need to change the settings at all and simply can press the "Generate plate" button. (Default settings: MX switches and 19.05 mm row and column distances.)
As a result, the plate builder will prepare you a DXF file for download, which is exactly what you need to laser cut the plate.
Plate production
Before sending the plate file (DXF) to the laser cutter of your choice you can check it e.g. in Inkscape. (To resize the page to the drawing press Ctrl+Shift+R.)
The cutouts for switches should be fine but you can finetune the outline of your plate in Inkscape much easier compared to the plate builders.
Once finished, you can order your custom plate from quite any online service (Ponoko, lasergist, laserboost) or even better look for a local company in your city.
All you have to do is uploading/sending your DXF file to them and deciding on the plate material and finish.
Plate material
The most popular plate materials are probably 1.5 mm stainless steel and 3 mm acrylic. FR4, aluminium, brass or even 3D printing are further options. If you're not yet sure about your layout design, you can even try cardboard prototyping.
I personally would go with the steel one. It's rigid, looks cool, and the 1.5 mm thickness is just perfect for the switches to snap in.
Thin acrylic is prone to break so you need at least 3 mm. However, the 3 mm one is too thick for the switches to snap in and you'll have to glue them in which is a mess.
More on materials and the whole odering process in my keyboard plate manufacturing write-up.
Manufacturing and shipping your plate can take some time. (One more reason to look for a local company.)
The finished plate
Wow! Holding your brand new plate in your hand feels mesmerizing.
You can put your switches (even with caps) into the plate to get a feel of it. Hey, it already looks like a keyboard! You can even pretend as if you were typing! It just doesn't work yet.
Handwiring or PCB
On the way to breath life into the machine you have two options: handwiring or designing and manufacturing a PCB.
Building a single keyboard (as opposed to mass production or even a small batch) can be done perfectly by hand (handwiring). I mean, you will need to solder a lot of things even if you design and order a PCB. (Let's leave PCB design for the (upcoming) advanced guide.)
Controller
Either way, you have to decide on the controller. The controller is the brain of your project and you have to choose it according to the number of pins required.
The word controller is used ambiguously. A microcontroller (or MCU) is a really tiny self-contained computer. A chip. Hard to solder, hard to work with.
Popular MCUs for keyboards are e.g. the Atmega32u4, Atmega32A etc.
But if you are reading this beginner guide you want probably a development board instead.
A development or breakout board (also referred to as a controller) is the microcontroller chip put on a small piece of PCB sorrounded with all the necessary components for it to work (capacitors, diodes etc.) and the pins "broken out" for easier access and soldering.
What's a pin? To make it simple, you need a pin (a port to read switch data) for each column and each row of your layout.
I/O pin or GPIO pin is a more appropriate name (abbreviations for Input-Output and General Purpose Input Output) because there are other kind of pins which we cannot use to read the status of a keyswitch (VCC, RAW, GND, RST etc.).
Common controller boards
The cheapest option is a Pro Micro from Aliexpress ($3-4), but there are other controllers with more pins. Check this list of common controllers.
#pic pin
Number of pins required
To make it simple, you need a pin for each row and column in your matrix.
For more info check my write-up about the keyboard matrix, or for larger keyboards the more advanced duplex matrix guide.
Each extra feature (status LED, underglow, backlighting, rotary encoder or display) requires one or more additional pins.
E.g. the keyboard in our example can be driven by a controller featuring at least 18 pins (4 pins for the rows and 14 pins for the columns). This can be done with quite any common controller.
However, for your cheapest option, a Pro Micro) 18 pins are the upper limit. If you would like underglow or a rotary encoder, features consuming more pins, take a look at the duplex matrix concept.
With a duplex matrix you end up with a 8x7=15 pin setup instead of the original 4x14=18 one. This way you have saved three extra pins for the underglow or an encoder.
Handwiring
Once you settled on the controller, it's time to wire things up.
A keyboard is a quite dumb circuit. You have a bunch of switches arranged into columns and rows. All you have to do is to connect them to the controller and each other.
In addition, you will need diodes for every switch. (I write about the reasons here.)
As simple a keyboard circuit may look, each switch has 4 solder joints (2 for the switch and 2 for the diode), so on a standard 105-key ISO keyboard you have to solder 420 times. Plus the controller pins. Plus LEDs, encoders and displays if you want those too...
(Again, with a PCB you would have to do exactly the same amount of soldering. What you spare is the wires and their arrangement.)
Handwiring means simply soldering the switches and diodes together and finally the columns and rows to the controller. The best way is probably learning from real-life examples, i.e. from build logs.
PCB design
If you chose handwiring you don't need a PCB.
I recommend handwiring as a first project. The experience and understanding of matrices you pick up during handwiring will come in handy with PCB desing too.
If you insist on having a PCB you better start with reading this guide. However, PCB design is a whole other world on its own with lots of pitfalls.
A free and popular PCB designer tool is KiCAD. The output of this stage will be your Gerber files. You can order your PCB from a manufacturer by presenting these files to them.
Also, the minimum order quantity of PCBs is usually 5 pieces.
Programming
Designing your own keyboard is great but it means you have to make the program for yourself too.
The QMK firmware is probably the most popular one. It has a good documentation and you won't really program anything at this stage, you just config this thing by editing text files.
The process of writing the firmware onto the controller (flashing) can be confusing, but you will nail this eventually and the next attempt will be much quicker and easier.
More about the process of firmware building and flashing in a separate guide.
Custom keycaps
Make yourself a favor and use only 1u keys. No compatibility issues, no stabilizers, no headache.
If your concept involves keys with non-standard width/size/shape: Just learn touch-typing and use keys with the same width regardless of their labels.
And 3D printing is always an option too.
Conclusion
Building a keyboard from scratch is very rewarding. This is the only approach where you can tailor a keyboard to your hands and fingers. As you can see, all the necessary tools, guides and general info are freely available.
Now that you know the necessary steps, you are ready to build great keyboards.
Thanks for reading. Let's start to design something right now! Good luck!
As an inspiration you may check the great projects selected weekly for the Keyboard Builders' Digest magazine or my collection of split keyboards.