Build a mechanical macropad
ActivitiesProjects
Assemble a small programmable keypad and assign keys to shortcuts in a program you use.
Building a mechanical macropad means assembling a compact keypad from mechanical switches, wiring those switches to a microcontroller, and programming each key to trigger chosen computer actions. A pad does not need to imitate a full keyboard's layout or key count: a four-key build can handle select all, cut, copy, and paste, while a ten-key PCB build can hold a larger set of shortcuts or macros.
Choosing how to build the hardware
Three common construction methods determine your tools and assembly order.
- Hot-swap sockets: Instead of soldering switches, fit them through a mounting plate and press them into hot-swap sockets on the board, aligning each switch's legs carefully so none bend.
- Purpose-made PCB: Solder switching diodes (such as 1N4148), compatible switches (such as Cherry MX-compatible or Alps switches), pin headers, and a microcontroller onto a dedicated circuit board. A ten-key build like the Navi10 with a KB2040 also adds a small LED, a resistor, screws, and spacers; you align each diode's marked side to the PCB silkscreen, install the headers and switches, attach the controller, and join the plates, following the specific board's instructions for controller orientation and clearance.
- Hand wiring: Snap switches, along with plate-mounted stabilizers for any keys in your layout that use them, into a plate, then wire the circuit point-to-point with one through-hole diode per switch, wire, cutters, and a soldering iron.
Direct pins versus a diode matrix
A small pad does not always need a keyboard matrix. On a four-key build like Adafruit's Pico Four, one leg of every switch can share a ground connection while the other leg runs to its own GPIO pin, such as GP0 through GP3.
When you want more keys without running out of controller pins, wire the switches in a row-and-column matrix. Each switch connects one row to one column when pressed; the firmware scans one column at a time and reads the rows to register a closed circuit. Because switches share rows and columns, the combined count of rows and columns only needs to fit within the controller's usable I/O pins.
Sharing lines introduces a quirk: without diodes, pressing three keys in a 2-by-2 block lets current sneak around the circuit and register the fourth, unpressed key, an effect called ghosting. Placing one diode at each switch blocks that unwanted path, provided every diode is oriented consistently to match your wiring and firmware configuration.
Bench safety and keeping wires apart
Soldering requires steady ventilation or a fan so you are not breathing rosin smoke. When hand wiring with stranded wire, avoid melting the wire's insulation, which generates additional harmful fumes.
When bare diode legs form the rows of a hand-wired matrix, use insulated wire for the crossing columns so rows and columns cannot short together. In Adafruit's Pico Four build, insulating tape covers exposed solder pads and the facing side of the enclosure before the case is closed. Record which controller pin connects to each row, column, or direct switch while the wiring is still open in front of you.
Programming shortcuts, macros, and layers
Your firmware configuration has to mirror the physical circuit. In QMK, a diode matrix specifies its row and column pin arrays along with the diode direction (`COL2ROW` or `ROW2COL`), whereas a direct-pin build uses `matrix_pins.direct` instead; a layout macro then maps each physical switch location to its position in the matrix.
Simple shortcuts, such as pairing a modifier with A, X, C, and V for select all, cut, copy, and paste, are often enough on their own, though you need to adjust the modifier key for Mac versus Windows. When you want one keypress to type out a word or phrase, QMK's `SEND_STRING` macro emits a sequence of characters from a custom keycode. Because `SEND_STRING` defaults to a US ANSI host layout and works on ASCII, other keyboard layouts require a supported language lookup header, and Unicode strings such as accented characters cannot be passed directly.
Layers stretch a small key count further by assigning different actions to the same physical switches depending on which layers are active. QMK checks active layers from highest to lowest and executes the first entry that is not marked transparent (`KC_TRNS`), allowing transparent positions to fall through to whatever sits on a lower layer.
Flashing and troubleshooting dead keys
Once the firmware is compiled, put the microcontroller into reset or bootloader mode to flash it—for example, selecting the compiled file and controller in QMK Toolbox—keeping in mind that the exact flashing sequence depends on the controller. Wait to secure a separate controller inside the enclosure until every key works.
Test each switch in a keyboard tester or text editor and write down any position that fails. On a hand-wired matrix, inspect the switch and diode joints—a loose diode can leave part of a row unresponsive, while loose column wiring can affect part or all of a column—and check the controller connections as well. Confirm the keymap and firmware flash, and use a multimeter to check whether a suspect switch actually closes when pressed.
