How to Build Your Own Mechanical Keyboard

As someone who enjoys playing intense games like League of Legends, Mario Kart, and gun battles, I destroyed my Wrangler mechanical keyboard with my vigorous typing. To replace it, I purchased an RK100 online as a suitable replacement. At the time, my understanding of mechanical keyboards was limited to gaming and work purposes. However, when I learned that I could DIY a mechanical keyboard, I fell in love with it!

This experience sparked a 4-month journey that transformed me from a novice with limited knowledge of linear and paragraph axis switches to someone who is now waiting to process CNC shells for the first customized mechanical keyboard.

Though I am still a newbie, I can’t wait to share this exciting experience. I must admit that my article is lengthy and may contain errors. Therefore, I welcome any feedback or corrections that readers may have and encourage you to contact me via email with suggestions.

Table of Contents

Customize Unique Skins

When it comes to customizing your mechanical keyboard, it’s important to make it stand out and be unique. Otherwise, it would be more practical to simply buy a pre-made keyboard online. This is why I made it my priority to customize skins. After much contemplation, I decided to customize its appearance based on my interests. As a big fan of Michael Jordan, I thought a Jordan-related theme would be fitting.

One of my favorite moments in NBA history is from the 1998 NBA Finals when Jordan stole the ball from Karl Malone and scored the winning basket in the last 5.6 seconds of the game after a series of impressive moves. It’s a classic moment that’s been passed down from generation to generation, and I wanted to commemorate it with the keyboard I designed. I’ve named this self-made mechanical keyboard with a youthful theme “Last Shot“.

Theme-Related Elements

The overall design direction has been confirmed, and now we need to find some related elements to make it more closely aligned with the theme. I am approaching this from two directions: players and teams. The relevant elements I am preparing include: 23 (jersey number), horns (Bulls’ logo), red and black color scheme (AJ14 Black/Red), 665X4X9X2 (past honors combination number), 5.6Sec (final shot time)…

Bulls hero Bulls logo Black and red AJ14

Keyboard Structure

When assembling a mechanical keyboard yourself, choosing the right structure is crucial. Although the “gasket mount” structure is currently the most popular, it may be too complex for beginners. Therefore, I decided to go with the relatively simpler “top mount” structure, where the mounting plate is directly fixed to the top case.

7 Mechanical Keyboard Structures

Since I’m DIY-ing a mechanical keyboard, why not design a unique set of keycaps as well? To ensure quality and aesthetics, I chose gold powder switches. These switches not only perform excellently but also add a touch of elegance to the keyboard. To further enhance the keyboard’s stylish look, I selected a copper mounting plate paired with a unique champion yellow color scheme, adding more personality to the keyboard.

Initially, I planned to customize a dedicated PCB and handcraft red and black cables, but due to the high costs, and considering that the TechSparks project itself is non-profit, I had to opt for more budget-friendly alternatives.

Custom Mechanical Keyboard Layout

Brief Introduction to Keyboard Arrangement

  • Full Size

The full-size keyboard layout refers to a traditional keyboard case that includes 104 keys, such as number keys, function keys, arrow keys, and a separate keypad. If you plan to use these homemade mechanical keyboards regularly, sticking with the traditional layout may better suit your habits.

Full Size Keyboard layout

  • 90%

Compared to a full-size keyboard, the 90% keyboard layout removes some gaps, making it more compact and aesthetically pleasing. For designers or heavy keyboard users, the 90% keyboard layout could be an excellent choice.

90% of keyboard layouts

  • Tenkeyless

Tenkeyless (TKL) keyboards are designed without the independent numeric keypad and instead feature an 87-key layout. This makes them ideal for users who prioritize compactness and space-saving designs, especially gamers and computer professionals. A reliable and stable TKL should support multiple switch types, provide excellent key rollover and anti-ghosting, and ensure optimal performance.

Tenkeyless Keyboard layout

  • 60%

The 60% configuration is similar to that of a Mac keyboard, with only the main keypad retained and the top “F keys” removed. The functions of F1-12 are instead accessed through combination keys, resulting in a perfectly proportioned keyboard. However, if you frequently use the “~” key when typing, customizing this type of keyboard may not be the best choice for you.

60% Keyboard layout

  • Split

Split keyboards feature an ergonomic design that divides the keyboard into left and right sections, each with its own independent PCB connected by a flexible cable or other connectors. This split layout promotes comfort and encourages healthy work practices, reducing hand fatigue caused by extended keyboard use.

Split Keyboard layout

Brief Introduction to Keyboard Layout Editor

After selecting the keyboard arrangement, you need to use the keyboard layout editor to adjust the position and appearance of each physical key. Although its name might sound a bit straightforward—“Keyboard Layout Editor”—it is indeed a useful tool. When you open it, you will see an interface similar to the one shown below. I have labeled the potentially useful functions in order and will explain them in the following text:

Website page for the Keyboard Layout Editor

  1. Preset: After entering the interface, you will see the layout that needs to be preset. You can choose an arrangement that matches your expectations. For example, if you want a 60% keyboard, you can remove the excess keys from the selected full-size layout.
  2. Add Key: Add a key to the layout page.
  3. Delete Keys: This feature is somewhat redundant and has the same effect as pressing the DEL key on your keyboard.
  4. Undo, Redo, Cut, Copy, Paste: These are self-explanatory features.
  5. Properties: This feature is very important as it includes basic settings such as text, color, width, and height for your keycaps.
  6. Top Legend, Center, Bottom Legend: These three features allow you to input text on a specific keycap in the first column, with the text positioned in the top, middle, or bottom layer.
  7. Width and Height of a Single Key: The width and height of the keycap are measured in a basic unit called “U.” Typically, a letter key is 1U, the CTRL function key is 1.25U, the space bar is 6.25U, and the Backspace key is 2U. Here, you can customize the width and height of these keys according to your preferences.
  8. Raw Data: This is the most crucial feature of the editor. After adjusting all the arrangements, an unintelligible code is generated in the text box, which must be saved. You can save this code in a local text document so that the next time you create a positioning board or change your arrangement, you can simply copy this code and make adjustments based on the saved layout, rather than starting from scratch.

Raw data

Drawing the Positioning Plate

After completing the keyboard layout, we need to use Plate & Case Builder and AutoCAD to draw the positioning plate. The former is used to generate the positioning plate, while the latter is a powerful engineering drawing software developed by Autodesk. Don’t worry; for DIY mechanical keyboard projects, we only need to use some basic features.

First, open Plate & Case Builder then you will see an interface similar to the one shown below. As before, we have labeled the tools you need to use and provided explanations:

Plate & Case Builder's web interface

  1. Plate Layout: Copy the code generated in the Keyboard Layout Editor from the previous section into the text box.
  2. Switch Type: Four switch options are provided here. If you are not familiar with them, just select the first one like I did.
  3. Stabilizer Type: It is recommended to choose “Cherry Only.”
  4. Draw My CAD: Once all the work is completed, click this button to go to section “5,” which is the “CAD output”, as shown in the figure below:

CAD Output column

In the interface shown above, you’ll notice three download buttons located in the upper right corner. You can choose from different formats, such as SVG, DXF, and EPS.

Below the positioning board, there are two numbers of significant importance. These numbers are used to set the width and height of the positioning board, measured in millimeters. I’ve selected a width of 347.665 mm and a height of 119.064 mm.

Once we download this file, we can open it in CAD, as depicted in the figure below:

CAD interface

AutoCAD is a tool that relies heavily on shortcut keys. If you want to know about it, you can search it on Google. Here we briefly introduce it:

  • L — Straight Line
  • C—Circle
  • TR — Trim Redundant Lines
  • O—Offset Side
  • M — Mobile
  • CO — Copy
  • DIV—Several Paragraphs on One Side
  • E — Delete
  • RO—Rotate
  • MI—Mirror
  • Space / Right Mouse Button — Confirm

For example, if you want to draw a straight line on this software, you can complete it according to the following process:

Tap “L”→space to confirm→left mouse button to select the starting point of the line→confirm the direction→input the value of the line→space to confirm again.

well-designed keyboard layout

Upon comparing the two pictures above, you’ll notice that the positioning plate for my keyboard is almost entirely manufactured, with a self-made logo on the right-hand side.

Due to the use of the TOP MOUNT structure, there are four protruding fixed structures on the upper and lower sides of the positioning plate. To ensure that the keyboard remains intact and does not fall apart under heavy use, screw holes must be added to these structures before they are combined with the keyboard shell.

You might be wondering how to set the width of the fixed structures. In reality, this is quite simple to calculate. Although the positioning plate we’ll be working on later is a copper fixture, there must still be a specific distance between the screw hole and the edge. The hole must be positioned 2mm from the edge.

We used screws with a 2mm diameter stud. To account for any tolerance issues, the screw hole diameter should be slightly larger than 2mm—typically, this value is 0.2mm. Therefore, we can deduce that the diameter of the screw hole is 2.2mm, the distance from the edge to the screw hole is 2.0mm, and hence the width of the fixed structure of the positioning plate is 2 + 2.2 + 2 = 6.2mm.

Adjustment Matrix

In the content above, we used CASE BUILDER to manufacture the keyboard’s positioning board and modified it into a suitable TOP MOUNT structure using software. Now, we will proceed to generate the configuration file in JSON format:

What is the JSON File For

  • This JSON file is used to layout the matrix of your keyboard. While the word “matrix” may sound very technical, it is actually quite simple. It refers to the rows and columns of your keyboard, forming an XY coordinate system.
  • This file acts as a linking file, as it is essential for preparing the PCB for the keyboard. With the exact rows and columns defined, we can accurately draw the schematic PCB diagram.
  • Within this file, you can define the key values of the keyboard, meaning you can assign specific functions and roles to each key.
  • After drawing the PCB, you can adjust the rows and columns to correspond to the pins of the main control chip.
  • Finally, this process will allow you to generate a HEX file, which is used for flashing the firmware.

Adjustment Process

Enter the Keyboard Firmware Builder, then copy the code that we generated in the Keyboard Layout Editor into position 1 in the image below, and click “Import” to import it.

Keyboard Firmware Builder

After importing, it will appear as shown in the image below. As usual, we will explain the numbered sections 1-10 in order.

Interface after importing data

  1. Keyboard Matrix Diagram: By adjusting the ROW and COL values, the layout can be made more comfortable, making it easier for us to draw the circuit schematic diagram.
  2. ROW Value: This refers to the number of rows in the keyboard matrix.
  3. COL Value: This refers to the number of columns in the keyboard matrix.
  4. Select Row or Column: At this stage, this can be temporarily ignored, but it is crucial. It needs to be synchronized with the schematic diagram when generating the firmware; otherwise, the keys on the keyboard may not function properly.
  5. PINS: Here you can adjust the pin numbers for all rows and columns corresponding to the main controller, as well as the pins for CAPS LOCK and RGB lights. After clicking, the screen will display as shown below. The ATMEGA32U4 is the main controller chip on the PCB. ROW & COL are used to adjust the corresponding pin numbers. Once the schematic is completed, we can enter the corresponding row and column values. CONFIGURE LED PINS is used to control the pins for the keyboard lights.

PINS all ranks

  1. KEYMAP: Refers to key values, which are layered. Typically, there are tier 0 and tier 1 layers. Layer 0 is the base layer, containing commonly used symbols and letters. Pressing the FN key switches to layer 1.
  2. Skip
  3. Skip
  4. Settings: After entering, as shown in the image below, enter the name of your custom keyboard in the Layout Name field. Bootloader Size and Backlight Levels do not need to be configured and can be left at their default values. WS2812 LEDs is used to specify the number of LEDs on the keyboard. Set this number to be the same as the number of keys on the keyboard so that the LEDs will light up while you type. After completing all the settings, click Save Configuration to generate a JSON format configuration file.

settings

  1. COMPILE: Once all settings are completed, go to COMPILE and generate a HEX format file. This file will be used for subsequent firmware flashing.

Design Your PCB

Unlike traditional keyboards, mechanical keyboards use mechanical switches to control input, and the PCB is the key component that enables the keyboard’s functionality. Therefore, you must design it yourself!

Further Reading: Mechanical Keyboard vs. Membrane Keyboard

Before starting the design, it’s necessary to choose a design software that suits you. You have many options to choose from, including popular ones like Altium, KiCad, and DesignSpark PCB. Since I’m Chinese, we’re using software developed by JLCPCB for this project, as it’s more affordable, and we also plan to have them manufacture it afterward. If you’re unsure about which design software to use, you can check out the “Best PCB Design Software List”.

Since this software seems to be available only in Chinese, I won’t go into detail about the entire design process. However, these three previously written articles might help you: “PCB Layout Design Guide for Beginners”, “How to DIY Design PCB Layout by Yourself” and “How to Build Your Own Keyboard PCB”.

When designing the PCB for your mechanical keyboard, keep a few things in mind:

  • It’s recommended to choose the AU package for the chip, as its pins extend outside the chip, making subsequent soldering easier.
  • When setting the grid size, it’s advised to use mil as the unit of measurement.
  • The distance between the two components below the Type-C port should be kept as consistent as possible.
  • The D+ and D- lines should be routed as differential pairs to maintain uniform trace lengths.
  • The 16MHz crystal oscillator should be placed as close to the main controller as possible.
  • On the reserved island on the right side of the screen, we need to open the local routing program and choose to ignore already routed lines when performing automatic routing; this will greatly improve the success rate.
  • Export the BOM file and follow it when purchasing and soldering components.

Once everything is completed, generate the Gerber files and submit them to the manufacturer. Here’s the design I created:

Designed keyboard PCB

Mechanical Keyboard 3D Modeling

Modeling is the process of designing and visualizing objects by creating virtual three-dimensional (3D) models. Through 3D modeling, we can customize the shape, dimensions, and details of a mechanical keyboard in a virtual environment and conduct virtual testing. To complete this process, you need to use 3D modeling software. The most commonly used software is SolidWorks; however, I find it less user-friendly, and since designing a custom mechanical keyboard is relatively simple, I used Shapr3D instead. Upon entering the interface, it looks like this:

3D modeling software interface

The basic dimension settings are as follows:

  • The positioning board needs to maintain a certain distance from the upper surface of the keyboard shell.
  • The size of the bottom edge of a 1U keycap is approximately 18mm x 18mm.
  • The distance from the edge of the positioning plate to the edge of the side shaft hole is 3mm.
  • The height of the overall keyboard’s upper shell should be kept at 20mm as much as possible.
  • Each positioning plate’s shaft hole measures 14mm x 14mm.
  • The positioning plate is 1.5mm thick.
  • When processing the positioning plate, the size of the shaft hole should be 14.1mm x 14.1mm.
  • The distance between the PCB and the positioning board is 3.5mm.
  • The PCB has a thickness of 1.6mm.
  • For a hot-swappable PCB, the thickness is approximately 1.85±0.1mm.

Keyboard Size Design Drawing

If you’re using a split PCB, there will be a terminal interface on the circuit board for connecting the power supply.

SpecValue
Rated voltage250V AC/DC
Rated current2A
Circuits2P-20P
Applicable wire gaugeAWG24#~30#
PackagingBag/Tube/Reel
Operating temperature-25°C~+105°C

Make the Casing

3D Printing

Even if you haven’t used 3D printing technology before, you’ve likely heard of it, as it is widely used across various industries. With the advancement of technology, this method is no longer limited to materials like resin; it can now print valuable materials such as metal and nylon. If we use this technology to make mechanical keyboards, it can be divided into two categories:

FDM: This stands for Fused Deposition Modeling. The primary materials used in this process are ABS and PLA. Simply put, this technique involves layering. However, it tends to produce a less refined product with larger tolerances, meaning more post-processing will be required on your part.

FDM

SLA: This refers to the technology of light-curing resin. It is strongly recommended to use this technology when making your own keyboard. Compared to FDM, SLA produces a higher-precision finished product, achieving up to ±0.1mm accuracy.

SLA

CNC Machining

CNC technology involves the use of CNC milling machines for metal product prototyping. Unlike the stacking method used in 3D printing, CNC relies on a “subtractive” process, where a cutter head is used to remove material from metal to create the desired shape. However, due to the limitations of the cutter head, achieving a perfect right angle at certain inner corners of the model may not be possible. The smallest cutter head may have a diameter of 1mm, while the inner corner of a keyboard case typically measures 0.5mm. Despite this, the inner corner may still appear visually as a right angle, with minimal impact on the final product.

CNC machine tool

There are few points of concern when using CNC machining technology, as its accuracy can reach up to ±0.01mm. Essentially, if your model adheres to the cutter head diameter mentioned above, it can be flawlessly realized by CNC technology. A 0.1mm assembly gap is usually sufficient for a perfect assembly, especially if anodic surface treatment is applied. However, note that if your keyboard model is too complex, the processing cost may rise significantly, as the different cutter head sizes and fine details require more labor-intensive work.

Component Soldering and QMK Firmware Flashing

Before soldering the components, you need to revisit the Keyboard Firmware Builder website and further refine your settings. Ensure that the ROW and COL pins mapped in your schematic match the configuration here, then generate a HEX file to flash the firmware.

Generating the HEX File

Open the PCB schematic you’ve designed in your design software, as shown in the image below:

Corresponding pins on the schematic

In the image above, we have clearly marked circles and arrows. It’s fairly straightforward to understand that ROW0-ROW5 correspond to the PF0-PF7 pins on the main control chip, and COL0-COL16 correspond to the PC7-PB1 pins. In simple terms, the main control chip manages all the row and column pins, with each pin controlling a row or a column. For example, if you want RGB and CAPS LOCK lights, your number of rows plus columns must equal 23.

With this information in mind, you can log in to the Keyboard Firmware Builder website, upload the previously generated JSON file, and then go to the PINS page. There, you will see:

PINS page bar

That’s right, as you’ve understood, on the PINS page, you can map each ROW and COL to the corresponding pin on the main control chip and select them from the dropdown menu.

CAPS LOCK corresponds to the E6 key, while the WS2812 Strip at the bottom corresponds to B0, which is your LED strip. At this point, most of the challenges have been resolved, and now you can proceed to the KEYMAP section, as shown in the image below:

KEY MAP

To set the FN key, go to LAYER 1. Previously, we set the reset key, which means FN + ESC is the reset function. This time, we will set up the lighting-related keys. After completing the configuration, save the JSON file and go to COMPILE to download the HEX file for your mechanical keyboard.

Below are the lighting-related keycodes from the QMK manual:

  • BL_TOGG: Backlight (shaft light) switch
  • BL_DEC: Backlight dimming
  • BL_INC: Backlight enhancement
  • BL_STEP: Backlight step
  • BL_BRTG: Backlight breathing
  • RGB_TOG: RGB bottom light switch
  • RGB_MOD: RGB bottom light mode switch forward. Hold shift and press RGB_MOD to switch backward.
  • RGB_RMOD: RGB bottom light mode switch backward. Hold shift and press RGB_RMOD to switch forward.
  • RGB_M_P: Static mode
  • RGB_M_B: Breathing mode
  • RGB_M_R: Rainbow mode, single color gradient
  • RGB_M_SW: Rotation mode, rainbow gradient
  • RGB_M_SN: Snake mode
  • RGB_M_K: Knight Rider mode
  • RGB_M_X: Christmas animation mode
  • RGB_M_B: Static gradient animation mode
  • RGB_M_T: Static three-color transient
  • RGB_HUI: RGB hue addition
  • RGB_HUD: RGB hue subtraction
  • RGB_SAI: RGB saturation plus
  • RGB_SAD: RGB saturation minus
  • RGB_VAI: RGB brightness plus
  • RGB_VAD: RGB brightness minus

Component Soldering

Before soldering the components, you should first export the BOM file from your design software and then solder the components according to the corresponding numbers on the PCB silkscreen. If you are unsure of the specific steps, it is recommended to read “How to Solder Components on a PCB Board for Beginners“. Here are some simple tips:

  • Make sure to tin the pads before attaching the Type-C port.
  • Ensure that the solder doesn’t connect unwanted areas.
  • Properly manage the amount of solder paste used and make sure it melts thoroughly.
  • Don’t rush to apply more flux during bridge soldering.

After completing the soldering of the main control chip and its surrounding components (such as the 100nF and 470nF capacitors, crystal oscillator, and two 22Ω resistors for the Type-C interface), connect the Type-C interface to your computer. If the soldering is correct, the computer should recognize a new device in the Device Manager, indicating successful soldering.

Next, you’ll need software called ZADIG. After opening the software, go to the OPTION menu in the toolbar and select LIST ALL DEVICES. Then, choose the 32U4 entry from the dropdown menu, select libusb win32 on the right, and click INSTALL to install the driver. Once installed, the hardware identification name in the Device Manager should change to ATMEL 32U4. Finally, use the QMK TOOLBOX software to flash the firmware. Although it may sound intimidating, it’s essentially just copying the HEX file to the chip.

Flash the firmware

Here we will be using the QMK TOOLBOX software. It should be noted that some users may have a standalone file for this software that can be run by double-clicking. However, if you encounter issues entering DFU mode, it is recommended to download and install the QMK TOOLBOX installation program from the official QMK website. During the installation, you will be prompted to install the necessary drivers, and it is important to select “yes.” This should resolve any issues with entering DFU mode.

QMK TOOLBOX software

After plugging in the keyboard PCB and pressing the KEYSWITCH button, a line of yellow text will appear in the window, indicating that you have entered DFU mode. Select the downloaded HEX file from the website in the LOCAL FILE column, and click FLASH to flash your firmware.

Ending

You Might Be Interested

How to make a simple pulse meter
How to make a simple pulse meter

Get Your Heart Racing with a Simple Pulse Meter – Discover How to Build Your Own with Ease! Whether you’re a fitness enthusiast or just curious about your health, our

A Step-by-Step Guide to Using LVGL with ESP32
A Step-by-Step Guide to Using LVGL with ESP32

This guide illustrates how to integrate LVGL with the ESP32, enabling the creation of engaging graphical user interfaces for embedded systems. By configuring libraries and writing code, developers can enhance

mechanical keyboard pcb
A Must-Read Guide to Buying Keyboard PCB

The article provides a comprehensive guide to choosing a mechanical keyboard PCB, highlighting its importance in improving functionality, lifespan, and user experience. It explains the advantages of incorporating a PCB,

Build Own Keyboard PCB
How to Build Your Own Keyboard PCB

This comprehensive DIY keyboard PCB guide covers the design, soldering and assembly, programming, testing, and troubleshooting processes. It explains the importance of considering compatibility, additional features, ergonomics, programmability, and community

Scroll to Top