DEV Community

Cover image for Embarking on the Quest of Building Your Own Mechanical Keyboard
Jonathan Apodaca
Jonathan Apodaca

Posted on

Embarking on the Quest of Building Your Own Mechanical Keyboard

For way too long into my development career, I gave a disgraceful little thought to the equipment I used. No exception to this rule was paid to how I viewed and selected the keyboard that I would use as my main utensil. Recently, however, through a fortuitous chain of events, my path would finally cross with the world of mechanical keyboards, and I am forever ruined from using an OEM-keyboard as my daily driver.

Don't get me wrong: this journey is fraught with its own downsides. For one, the cost is significant. While one may hop on over to Best Buy and pick up a keyboard for the price of a decent 6-pack, one would be hard-pressed to get a good mechanical keyboard for under $50. Let alone when one begins to go down the road of the different customizations that can be applied to their existing hardware! Neglect to pay attention, and your pocket-book will be $300 lighter. However, for the patient, a great benefit waits at the end, and once greeted by its rewards, nearly impossible it becomes to return to former habits.

Why?

I was first introduced to the world of "superior" keyboards when I ran across a side-gig of Jeff Atwood's[1]: The Code Keyboard. The thought of a keyboard that was dedicated to the situation of my craft piqued my imagination. What then could be so enticing as to transcend the membrane keyboard I currently typed on at the time? I didn't previously know there were different types of switches for keyboards. Why? I suppose I just never really thought about it. I began reading that one could even customize their experience by choosing a specific switch, of which there existed at least 5 different choices[2].

I was just about sold, and proceeded to check out the store, that is until I saw the price-tag. At the time, $120 seemed a high premium for such a "frivolous" accessory. Then it seemed little more than a luxury. A mechanical keyboard could definitely not be a necessity.

Thought was hastily demoted to Aspiration: to be investigated at a later date, say, perhaps when the pocket-book was more willing to rise to the occasion.

Enter the 2018 MacBook Pro, which my boss bought me when I started a new job. Now there was a premium machine, in all her 6-core beastly speed. The honeymoon period was abruptly over, however, when the keyboard began to malfunction, and my text was increasingly littered with extraneous i's and u's. After a full day of coding, annoyance gave full birth to furry. Even that open-source debounce utility could not catch all of the double-key-presses. Now, Apple had issued a recall on the keyboard, but time could not be afforded. The machine would need to be admitted for a minimum of 3-days before the situation could be righted, and even at that, the procedure was a replacement with the same parts.

There were no two ways about it. Something had to be done. Amazon was cordially consulted, and her benevolence suggested a wireless solution. Something low-profile, say. Perhaps it would even fit atop the laptop's face-plate. Also, here is the perfect excuse you have been looking for to try out a mechanical keyboard.

Sold. It will be here in two days.

It was a dream for all of five minutes until I realized that whoever laid out the keyboard had placed the "?" to the right of the shift key. That purchase was quickly returned in favor of slightly more research.

I did finally end up with a keyboard that I liked. However, my sights were set high, and my new Aspiration was to build a fully custom mechanical keyboard.

Parameters - Many Dimensions

Alright, let's get down to the nitty-gritty details: just what are some of the benefits of mechanical keyboards? Let us reduce the whole world into a few attributes:

  • Size
  • Switches
  • Layout
  • Programmability

Keyboard Size

Keyboards come in many different sizes to accommodate many different use-cases, and they range from very small, to quite large! Sizes are typically rated in %-ages, e.g., "100%" / "65%" / "60%" / "40%" / etc. Loosely the percentage refers to how many keys are on the board. If you want to see some really tiny keyboards, just plug "40% keyboard" into Google, and enjoy the gallery.

The size that I prefer (for the moment) is 60%. This size seems to strike a good balance in that it is big enough that most keys are available without hitting too many "Fn" keys, and yet it is small enough that most keys are within reach without stretching my fingers too far. It also fits nicely in my backpack, atop my laptop, or cleanly on my desk leaving ample space for whatever else might live on my desk-related workspace.

Switches

Now here is where the customization begins to get fun. There being ample reading material on this topic already available, I will provide a short synopsis of the different types of switches here:

Linear
An even amount of pressure is required to actuate the key. Typically preferred by gamers.

Tactile
The key travels down, and activation coincides with a tactile "bump" the typist can "feel". This bump serves to involve the senses when typing quickly by providing queues to your brain about when keys have activated.

Clicky
Similar to tactile switches, a bump is present during actuation, along with an audible "click". This serves to involve not only the touch-sensation but also the typist's audio-sensory system to know precisely when keys have activated.

There are many, many different switches in each category, and there are even more categories than those presented here.

Layout

Mechanical layout is to be differentiated from "key mapping". The mechanical layout is the layout your eyes see when looking at the keyboard. "The rightmost key on the middle row is about so-wide". "There are keys in all four corners". That kind of stuff. That being said, withing a generalized layout, you are pretty much free to customize it as you see fit.

ANSI
This is the traditional layout you will find on most keyboards-- at least in the USA.

ISO
This layout has a double-row enter key, along with other differences.

JIS
Japanese layout

HHKB
This layout has fewer keys on the bottom row.

Ortholinear
Have you ever noticed that on pretty much every keyboard, the rows are staggered? Well, on an ortholinear keyboard, the keys are arranged in a grid. This has benefits like making many keys easier to reach, but you may need to re-train your brain to adjust!

Programmability

The programmability of custom keyboards is one of my favorite attributes. I like to make better use of my CapsLock key, but going about that through the usual OS-provided channels can be rather difficult on some operating systems. If the keyboard firmware itself lets you remap keys, then this is a cinch! Also, it's portable: I can plug my programmed keyboard into my Mac laptop, my Windows desktop, or my Linux desktop, and things just work.

Some keyboards have modes you can enter (via nefarious key combinations) that let you remap keys from the keyboard itself, others provide proprietary software, but by-and-large, my favorite keyboards are those that operate off of the open-source QMK firmware. The downside to QMK is that you may have to drop to a terminal compile your firmware when you want to remap keys. There is an online "configurator" that you can use, but QMK is definitely the least user-friendly of all these options. However, given its power, it is nonetheless my favorite option.

Also, if editing your keyboards C-code firmware sounds exciting, QMK offers that possibility to you as well. This is just really cool!

Parts

Initiating acquisition of the necessary parts you will need to build your keyboard is a matter of following a checklist. You will need:

  • Case - to contain all the other components in a presentable fashion
  • PCB ("Printed Circuit Board") - the electronic hub that connects all of the switches to a chip, exposing (usually) a USB interface. There are two major connector types: soldered, and "hot-swappable". Hot-swappable sockets hold the switches in by friction, allowing one to replace switches without going through the hassle of desoldering/re-soldering.
  • Plate - this is the part I most misunderstood: while the PCB has predefined holes that you will solder your switches to, each switch would have a little bit of wiggle-room if mounted to the PCB without a plate. The plate acts as a precise mount. It stands off of the PCB about 1/4", and each switch "clicks" into the plate, with their connector prongs sticking out below to connect to the PCB.
  • Switches - you have a lot of choices here! Some have an extra post (for extra stabilization) that a few PCBs do not have corresponding holes for: they can be easily clipped off with wire-cutters, so don't worry too much about that.
  • Stabilizers/Lubricant - stabilizers mechanically link the two sides of longer keys, so that when one extremity of the key is depressed, the whole switch depresses uniformly. You will want to lubricate the stabilizers for a smooth switch depression. I forgot to buy lubricant, and built my board without it: a decision I now regret, as now that the switches are soldered to the board, getting at the stabilizers would mean de-soldering every switch (they are under the plate)! I'm sure I can put some lubricant on a Q-tip and wiggle it between all of the pieces, but I really wish I had just done this right from the start.
  • Keycaps - just make sure the caps you buy are compatible with the switches. There are a variety of keycap profiles to choose from.
  • Supplies
    • Soldering iron
    • Solder: 60/40 lead-based is recommended
    • Solder sucker: get a high-quality one: the chances that you have to de-solder a switch during your build depend on a lot of factors, but I was left wishing that I had a more powerful solder-sucker than the one that came with the soldering-kit that I bought.

Assembly

Once delivery of all the aforementioned parts have been made, the first thing you will want to do is test the PCB. If it is not working, you want to correct the situation before going any further! This turns out to be an elementary exercise: plug the PCB into your computer, open a "key-tester" (either online, or download), and, using tweezers, short the connectors where the switches will go, one at a time, checking that the corresponding switch is detected in the key-tester.

One more important task presented itself to me when I took inventory of all my parts: the PCB I purchased (the DZ60) supports multiple layouts, and upon settling on a given layout, I laid each keycap out with respect to my chosen layout in order to make certain that everything lined up. This saved me any guess-work that would come later, and also aided me in locating the exact pin-locations where each switch would go (the DZ60 sometimes has multiple closely-positioned "alternate" holes to support small variances in switch-position). Once I had that figured out, I was ready to start assembling the keyboard!

The first things that must be mounted to the PCB are the stabilizers. There is one good way to learn to assemble your stabilizers: watch a video. These usually clip to the board. Once they are in position, you are ready to start placing the switches.

The switches clip into the plate, with their pins protruding downward into the holes on the PCB. You will want to take care to line them up precisely, especially if the plate allows any variance in position. A few of mine ended up slightly crooked, and though someone else might notice, I wish I had spent even a slight bit more time on this. Start by clipping a few switches in each corner of the board, to give the build added stability, then add more switches. Solder incrementally, then add more switches, rinse and repeat. Occasionally plug the board in and key-test the switches that you recently have added, just to be certain you have no "duds".

Once your switches are soldered to the board, you can screw the PCB/plate to the case! There is nothing extra to mention here, and at this point, anticipation of the end of the project runs high!

You can now perform what is most likely the most routing chore thus far: press each key-cap onto the switches! Plug the board in, and key-test once more for good measure.

Flashing

Phew! If you thought that was a process, there is yet an extra mile you can go, depending on the capabilities of the PCB which you purchased. This is the part I love the most, and is, in my mind, one of the chief reasons for owning a customized keyboard: flash custom firmware to your keyboard!

The PCB which I purchased supports QMK firmware (highly recommended), and the process for customizing the firmware can either be the "simple-mode", or the more thorough route:

  1. Use the QMK online configurator (UI)
  2. Fork the QMK repo and follow their documentation for creating your custom firmware
  3. ... there is yet one more option: use a combination of 1 + 2: the QMK command-line tools allow one to use the UI to produce a JSON configuration file that may be converted to C-code (via the command qmk json2c ...). This is the option I used.

Conclusion

Daunting? Yes, yet extremely rewarding. This is a project that I would highly recommend, especially if you spend the majority of your time typing. The keyboard is a typists' most necessary utensil, and being specially crafted removes yet more of the barrier know as the "human-computer-interface".

Post-Script: My Parts List

PCB: DZ60 revision 3.0 with Cherry stabilizers(6.25Ux1 2U x4)

Plate: DZ60 CNC - Plate-A(left shift is 2U)

Case: 60% aluminum low profile case - Silver

Switches: Gateron RGB brown

Key-caps: R1 XDA Dye-sub 60%

Footnotes
[1] Jeff Atwood co-founded Stack Overflow
[2] There are, in reality, many more switch choices than 5

Top comments (2)

Collapse
 
alexandreamadocastro profile image
Alexandre Amado de Castro

Where is the final picture of it assembly?

Collapse
 
jrop profile image
Jonathan Apodaca

It is the banner image at the top of the post.