Build a Mini Macro Keyboard with a Pi Pico
Share
A Raspberry Pi Pico running the right firmware enumerates over USB as a standard HID keyboard device, the same class of device as any off-the-shelf keyboard, so a computer accepts it without installing any special driver. The firmware's only job is to watch a handful of GPIO pins wired to tactile switches and, the instant one of them is pulled low, send the pre-programmed key combination that pin is mapped to. That is the entire mechanism behind a mini macro keyboard: a small board, a few buttons, and code that turns "pin 2 just went low" into "send Ctrl+C."
How does a Raspberry Pi Pico act as a USB keyboard?
The RP2040 chip on the Pico has native USB support, and CircuitPython's usb_hid module lets the board present itself to the host operating system as a Human Interface Device — the exact same device class a physical keyboard uses. Once that connection is established, the firmware imports a Keyboard object from the adafruit_hid library and calls methods on it to send keycodes. No companion app, no serial bridge, and no driver install: the computer already knows what to do with a HID keyboard the moment it's plugged in.
What parts does a mini macro keyboard need?
At minimum you need the controller, one momentary switch per key, something to hold the wiring together while you prototype, and wire to connect it all. Compoden's AI build assistant was asked to spec exactly this and returned a tray built around a Raspberry Pi Pico with six tactile push buttons — enough for a small but genuinely useful macro layout — plus a mini breadboard and jumper wires to connect them. The assistant also flagged a real gap: the Pico takes power over its USB port and has no barrel jack, so if you ever want to run the pad off anything other than a computer's USB port, you'd add a USB power source rather than the barrel adapter it initially suggested.
How do you assign a custom shortcut to each key?
Each button's leg is wired to a specific GPIO pin, and the firmware keeps a list that pairs each pin with a keycode sequence. In the live firmware run below, the code maps four buttons to GP2, GP3, GP4, and GP5 and pre-loads them with Copy, Paste, Cut, and Undo — ordinary Ctrl-key combinations sent through adafruit_hid.keycode.Keycode. Changing what a key does means changing which keycodes sit in that pin's entry; there's no separate configuration tool or reflashing a matrix table, since it's a handful of plain Python lines. Scaling from four buttons to the six in this build's actual parts tray just means adding two more pin-to-shortcut pairs to the same list.
Do you need a 3D-printed case?
Not to make the keyboard work, but you will likely want one to make it usable day to day. The parts tray the assistant returned for this build did not include an enclosure — it's a breadboard prototype of a Pico, six buttons, and jumper wires, which is exactly what you want for testing wiring and code before committing to a layout. A case (3D-printed, laser-cut, or even a small project box with drilled holes) is a separate step you source or design yourself once you've settled on where each key goes; it's not a part Compoden's assistant carded automatically, and this article isn't going to pretend otherwise.
Watch it built live
We asked Compoden's AI build assistant on the live storefront:
"I want to build a small macro keyboard with a few programmable buttons using a Raspberry Pi Pico"
It replied:
"This build lets you create a small keyboard with a few buttons that you can program to do specific tasks on your computer. You will connect the buttons to a small computer board, which then sends signals to your main computer, letting you automate actions or create custom shortcuts."
"You will use six Tactile Push Button Switch With Yellow Round Cap parts. These are your programmable buttons. They are passive components, meaning they don't generate power themselves. When you press one, it completes a circuit, sending a signal to the Pico."
The assistant carded a Raspberry Pi Pico, six tactile push buttons, a SYB-170 mini breadboard, and jumper wires — a four-line, six-key parts tray, screenshotted directly from the live build:
Watch the firmware get generated
Separately, on Compoden's VoltIQ firmware assistant, we asked:
"I'm building a mini macro keyboard with a Raspberry Pi Pico and 4 tactile push buttons. Write MicroPython (or CircuitPython) firmware using USB HID to send a different keyboard shortcut when each button is pressed."
The assistant answered:
"Here is the MicroPython firmware for your Raspberry Pi Pico macro keyboard. It will send a different keyboard shortcut (Copy, Paste, Cut, Undo) when each of the four buttons is pressed. The Pico will act as a USB HID keyboard device."
and gave setup steps in plain language: save the file as code.py on the Pico while it's in CircuitPython's USB mass-storage mode, install the adafruit_hid library in the board's lib folder, then "wire each button with one leg to a specified GPIO pin (GP2, GP3, GP4, GP5) and the other leg to GND." The generated source imports board, digitalio, and usb_hid, builds a Keyboard object from adafruit_hid.keyboard, and reads the four pins as a BUTTON_PINS list — the same pattern this build's six-button tray would extend with two more entries. Screenshot of the generated firmware tab:
Get everything in this build
| Part | Qty | Price | Add to cart |
|---|---|---|---|
| Raspberry Pi Pico ( RP2040) | 1 | Rs.410 | Add to cart |
| Tactile Push Button Switch With Yellow Round Cap | 6 | Rs.14 each | Add to cart |
| SYB-170 Mini Breadboard | 1 | Rs.20 | Add to cart |
| Male-to-Male Breadboard Jumper Wires (20 cm, 24 AWG) | 1 | Rs.40 | Add to cart |
| Total | Rs.554 | Add all to cart | |
Built and Backed by Compoden
Every part in the table above came straight out of Compoden's live parts tray for this exact prompt, at the prices shown at capture time, with real in-stock status. Compoden ships these components across India, and once you buy the kit it lands in Soldr.dev already pre-loaded with the same parts, ready to generate the wiring diagram, firmware, and test steps for your specific button count so you're not starting from a blank page.
FAQ
Do I need to install a keyboard driver for the Pico to work? No. Once the firmware is flashed, the Pico enumerates as a standard USB HID keyboard, which every major operating system already supports natively.
Can I use more or fewer than four or six buttons? Yes. The firmware pattern is a list pairing each GPIO pin with a keycode sequence, so adding a key means wiring another pin and adding one more entry to that list.
Does this build include a case for the buttons? Not in the parts tray captured for this article — it's a breadboard prototype of the Pico, buttons, and wiring. A case is a separate step you source or print once your layout is finalized.
What language does the firmware use? The generated firmware in this build is CircuitPython, using the adafruit_hid library's Keyboard and Keycode classes to send USB HID keystrokes.