# Pico Four Keypad

## Overview

Primary: Note the aluminum case shown in this guide is no longer stocked. All other aspects of this guide work including hardware and code.

![](https://cdn-learn.adafruit.com/assets/assets/000/105/415/medium800/hacks_picofour-3383.jpg?1634146397)

### Select all. Cut. Copy. Paste!

Much like the now infamous [Stack Overflow The Key](https://drop.com/buy/stack-overflow-the-key-macropad) copy/paste keypad, this small, beautiful keypad is designed to speed up your most important tasks!

You can build it with some hand wired mechanical keyswitches (no PCB or diode matrix required), and control it from a Raspberry Pi Pico RP2040 running CircuitPython.

The gorgeous silver aluminum enclosure houses it and you'll top it off with some delightfully gumdrop-y MA profile keycaps.

Warning: NOTE: this enclosure isn't custom designed for the Pico, so it's not a plug-and-play solution, but with a little patience it'll all fit just fine!

## Parts
Featured
### Raspberry Pi Pico RP2040

[Raspberry Pi Pico RP2040](https://www.adafruit.com/product/4864)
The Raspberry Pi foundation changed single-board computing [when they released the Raspberry Pi computer](https://www.raspberrypi.org/archives/723), now they're ready to do the same for microcontrollers with the release of the brand new **Raspberry Pi Pico**. This...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4864)
[Related Guides to the Product](https://learn.adafruit.com/products/4864/guides)
![Angle shot of Raspberry Pi Pico RP2040](https://cdn-shop.adafruit.com/640x480/4864-00.jpg)

Featured
### Kailh Mechanical Key Switches - 10 packs - Cherry MX Compatible

[Kailh Mechanical Key Switches - 10 packs - Cherry MX Compatible](https://www.adafruit.com/product/4996)
For crafting your very own custom keyboard, these **&nbsp;Kailh mechanical key switches** &nbsp;are deeee-luxe!

Come&nbsp;in a pack of 10 switches, plenty to make a small keyboard, or grab a few packs to build a full keyboard.

- Use these with our&nbsp;<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4996)
[Related Guides to the Product](https://learn.adafruit.com/products/4996/guides)
![Top down view of four piles of Kailh key switches in Red, Black, Brown, and Black variations.](https://cdn-shop.adafruit.com/640x480/4996-00.jpg)

Featured
### Orange MA Keycaps for MX Compatible Switches - 5 pack

[Orange MA Keycaps for MX Compatible Switches - 5 pack](https://www.adafruit.com/product/5175)
Dress up your mechanical keys in your favorite colors&nbsp;with a wide selection of gumdrop-like, retro, curvy, and stylish MA profile keycaps. Here is a 5 pack of **Orange MA Keycaps** for your next mechanical keyboard or&nbsp;<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/5175)
[Related Guides to the Product](https://learn.adafruit.com/products/5175/guides)
![Angled shot of five orange MA keycaps.](https://cdn-shop.adafruit.com/640x480/5175-00.jpg)

Featured
### Fully Reversible Pink/Purple USB A to micro B Cable - 1m long

[Fully Reversible Pink/Purple USB A to micro B Cable - 1m long](https://www.adafruit.com/product/4111)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also fully reversible! That's right, you will save _seconds_ a day by not having to flip the cable around.

First let's talk about the cover and over-molding. We got these...

In Stock
[Buy Now](https://www.adafruit.com/product/4111)
[Related Guides to the Product](https://learn.adafruit.com/products/4111/guides)
![Fully Reversible Pink/Purple USB A to micro B Cable](https://cdn-shop.adafruit.com/640x480/4111-02.jpg)

Featured
### High Temperature Polyimide Tape - 1cm wide x 33 meter roll

[High Temperature Polyimide Tape - 1cm wide x 33 meter roll](https://www.adafruit.com/product/3057)
 **Polyimide Tape** (sometimes referred to by the brand name **Kapton Tape** ) is an interesting addition to your toolbox! Polyimide Tape remains stable across a wide range of temperatures&nbsp;from about −269°C to +400°C.&nbsp;Along with aircraft,...

In Stock
[Buy Now](https://www.adafruit.com/product/3057)
[Related Guides to the Product](https://learn.adafruit.com/products/3057/guides)
![High Temperature Polyimide Tape - 1cm wide](https://cdn-shop.adafruit.com/640x480/3057-01.jpg)

# Pico Four Keypad

## Installing CircuitPython

[CircuitPython](https://github.com/adafruit/circuitpython) is a derivative of [MicroPython](https://micropython.org) designed to simplify experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the **CIRCUITPY** drive to iterate.

## CircuitPython Quickstart

Follow this step-by-step to quickly get CircuitPython working on your board.

[Download the latest version of CircuitPython for the Raspberry Pi Pico from circuitpython.org](https://circuitpython.org/board/raspberry_pi_pico/)
 **Click the link above and download the latest UF2 file.**

Download and save it to your desktop (or wherever is handy).

![circuitpython_Cat_UF2_download.png](https://cdn-learn.adafruit.com/assets/assets/000/098/753/medium640/circuitpython_Cat_UF2_download.png?1611157944)

Start with your Pico unplugged from USB. Hold down the **BOOTSEL** button, and while continuing to hold it (don't let go!), plug the Pico into USB. **Continue to hold the BOOTSEL button until the RPI-RP2 drive appears!**

If the drive does not appear, unplug your Pico and go through the above process again.

A lot of people end up using charge-only USB cables and it is very frustrating! **So make sure you have a USB cable you know is good for data sync.**

![raspberry_pi_one_one_two.png](https://cdn-learn.adafruit.com/assets/assets/000/125/993/medium640/raspberry_pi_one_one_two.png?1699493528)

You will see a new disk drive appear called **RPI-RP2**.

&nbsp;

Drag the **adafruit\_circuitpython\_etc.uf2** file to **RPI-RP2.**

![circuitpython_Cat_RPI-RP2_drive.png](https://cdn-learn.adafruit.com/assets/assets/000/098/756/medium640/circuitpython_Cat_RPI-RP2_drive.png?1611158210)

![circuitpython_Cat_drag_UF2.png](https://cdn-learn.adafruit.com/assets/assets/000/098/758/medium640/circuitpython_Cat_drag_UF2.png?1611158274)

The **RPI-RP2** drive will disappear and a new disk drive called **CIRCUITPY** will appear.

That's it, you're done! :)

![circuitpython_Cat_CIRCUITPY.png](https://cdn-learn.adafruit.com/assets/assets/000/098/759/medium640/circuitpython_Cat_CIRCUITPY.png?1611158312)

## Flash Resetting UF2

If your Pico ever gets into a really _weird_ state and doesn't even show up as a disk drive when installing CircuitPython, try installing this 'nuke' UF2 which will do a 'deep clean' on your Flash Memory. You will lose all the files on the board, but at least you'll be able to revive it! After nuking, re-install CircuitPython

[flash_nuke.uf2](https://datasheets.raspberrypi.com/soft/flash_nuke.uf2)
# Pico Four Keypad

## Installing Libraries

Alongside the core CircuitPython libraries (which are baked into CircuitPython), you'll also add the Adafruit HID Library to add keyboard features.

## Installing the Adafruit HID Library

Download the [library bundle](https://circuitpython.org/libraries) here.&nbsp;

Copy the **adafruit\_hid** folder from the bundle to the **lib** folder on your **CIRCUITPY** drive.

Before continuing make sure your board's **lib** folder has the **adafruit\_hid** library folder copied over.

![raspberry_pi_picokeeblib.jpg](https://cdn-learn.adafruit.com/assets/assets/000/100/314/medium640/raspberry_pi_picokeeblib.jpg?1614747910)

# Pico Four Keypad

## Build the Keypad

![](https://cdn-learn.adafruit.com/assets/assets/000/105/416/medium800/hacks_picofour-3369.jpg?1634146430)

Building the keypad involves snapping in your key switches, wiring/soldering them to the Pico, and closing it all up.

## Snap in Keys

First, use a small screwdriver to remove the base plate.

Then, snap in four keyswitches. It helps to use a consistent orientation as shown here.

![hacks_picofour-3371.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/417/medium640/hacks_picofour-3371.jpg?1634146450)

![hacks_picofour-3372.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/418/medium640/hacks_picofour-3372.jpg?1634146460)

![hacks_picofour-3373.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/419/medium640/hacks_picofour-3373.jpg?1634146470)

![hacks_picofour-3375.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/420/medium640/hacks_picofour-3375.jpg?1634146478)

![](https://cdn-learn.adafruit.com/assets/assets/000/105/421/medium800/hacks_picofour-3374.jpg?1634146604)

![](https://cdn-learn.adafruit.com/assets/assets/000/105/430/medium800/hacks_picofour_fritz.jpg?1634147621)

## Wiring Switches

Each switch needs to have one leg wired to common ground, and the other to a GPIO pin on the Pico.

Start by soldering black wire to connect the ground legs of each switch together (either can be the ground, so just pick one side and be consistent for neatness sake). Solder a few inches of wire to the end of one ground leg to run to the Pico.

Solder a wire about 4-5" (10cm) in length to the free leg on each switch. These will run to their own GPIO pins respectively on the Pico.

![hacks_picofour-3311.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/422/medium640/hacks_picofour-3311.jpg?1634146711)

![hacks_picofour-3312.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/423/medium640/hacks_picofour-3312.jpg?1634146718)

![](https://cdn-learn.adafruit.com/assets/assets/000/105/424/medium800/hacks_picofour-3313.jpg?1634146944)

## Pico Wiring

Now, run the wiring to the Pico.

- **Black wire to GND**
- **Blue to GP0**
- **Green to GP1**
- **Yellow to GP2**
- **White to GP3**

Be sure to skip the ground pin on the Pico that site between the GP1 and GP2 pins -- you can tell it's a ground because of the flat end on the copper pad.

![hacks_picofour-3315.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/428/medium640/hacks_picofour-3315.jpg?1634146979)

![hacks_picofour-3318.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/429/medium640/hacks_picofour-3318.jpg?1634146987)

## Insulate

Add some Kapton tape to the exposed pads and side of the enclosure to avoid any shorts.

![hacks_picofour-3376.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/431/medium640/hacks_picofour-3376.jpg?1634147686)

## Close It Up

Use one screw to fasten the acrylic base to the enclosure. (The other screw hole is obscured by the Pico board.)

Add two rubber feet to the bottom.

![hacks_picofour-3377.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/432/medium640/hacks_picofour-3377.jpg?1634147742)

![hacks_picofour-3381.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/436/medium640/hacks_picofour-3381.jpg?1634147863)

## Add Keycaps

Place your keycaps on the key switch stems and press down. You're ready to use the Pico Four Keypad!

![hacks_picofour-3379.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/434/medium640/hacks_picofour-3379.jpg?1634147808)

![hacks_picofour-3380.jpg](https://cdn-learn.adafruit.com/assets/assets/000/105/435/medium640/hacks_picofour-3380.jpg?1634147818)

## Deploy the Pico Four Keypad!

Plug it into your computer via USB cable, and now you can select all, cut, copy, and paste each with just a touch of the button!

![](https://cdn-learn.adafruit.com/assets/assets/000/105/438/medium800/hacks_picofour-3383.jpg?1634147892)

![](https://cdn-learn.adafruit.com/assets/assets/000/105/447/medium800/hacks_picofour-3384.jpg?1634147944)

# Pico Four Keypad

## Code the Four Keypad

## Text Editor

Adafruit recommends using the Mu editor for using your CircuitPython code with the Pico. You can get more info in [this guide](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

Alternatively, you can use any text editor that saves files.

## CircuitPython Code

Copy the code below and paste it into Mu. Then, save it to your Pico as **code.py**.

Warning: 

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Pico_Four_Keypad/code.py

## Testing

Even before we've wired up the mechanical keyswitches, you can test the code by shorting each of the four GPIO pins used to ground. This is the same as pressing a key. Just be careful not to short power to ground!

Use a text editor with some text in it to watch as your keys select all, cut, copy, and paste!

Info: 

## HID Keyboard Basics

[This guide page](https://learn.adafruit.com/adafruit-gemma-m0/circuitpython-hid-keyboard-and-mouse) has a great intro to CircuitPython HID Keyboard.

For even more details, check out the documentation at [https://circuitpython.readthedocs.io/projects/hid/en/latest/](https://circuitpython.readthedocs.io/projects/hid/en/latest/) which includes all of the keycodes and media codes you can use.

By importing the **adafruit\_hid** library into the program, you can make calls to send keyboard keys and media keys.

## Customization

You can have your keypad type other keys or key combos if you like. This is the section of code to adjust:

```python
KEYMAP = (
    ("Select all", [MODIFIER, Keycode.A]),
    ("Cut", [MODIFIER, Keycode.X]),
    ("Copy", [MODIFIER, Keycode.C]),
    ("Paste", [MODIFIER, Keycode.V]),
)
```

The string is only there for debugging/testing purposes. The section inside the brackets is where you can put your own keys and combos. Just remember to add a comma between each key in a combo.


## Guide Products

### Raspberry Pi Pico RP2040

[Raspberry Pi Pico RP2040](https://www.adafruit.com/product/4864)
The Raspberry Pi foundation changed single-board computing [when they released the Raspberry Pi computer](https://www.raspberrypi.org/archives/723), now they're ready to do the same for microcontrollers with the release of the brand new **Raspberry Pi Pico**. This...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4864)
[Related Guides to the Product](https://learn.adafruit.com/products/4864/guides)
### Kailh Mechanical Key Switches - 10 packs - Cherry MX Compatible

[Kailh Mechanical Key Switches - 10 packs - Cherry MX Compatible](https://www.adafruit.com/product/4996)
For crafting your very own custom keyboard, these **&nbsp;Kailh mechanical key switches** &nbsp;are deeee-luxe!

Come&nbsp;in a pack of 10 switches, plenty to make a small keyboard, or grab a few packs to build a full keyboard.

- Use these with our&nbsp;<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4996)
[Related Guides to the Product](https://learn.adafruit.com/products/4996/guides)
### Orange MA Keycaps for MX Compatible Switches - 5 pack

[Orange MA Keycaps for MX Compatible Switches - 5 pack](https://www.adafruit.com/product/5175)
Dress up your mechanical keys in your favorite colors&nbsp;with a wide selection of gumdrop-like, retro, curvy, and stylish MA profile keycaps. Here is a 5 pack of **Orange MA Keycaps** for your next mechanical keyboard or&nbsp;<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/5175)
[Related Guides to the Product](https://learn.adafruit.com/products/5175/guides)
### Fully Reversible Pink/Purple USB A to micro B Cable - 1m long

[Fully Reversible Pink/Purple USB A to micro B Cable - 1m long](https://www.adafruit.com/product/4111)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also fully reversible! That's right, you will save _seconds_ a day by not having to flip the cable around.

First let's talk about the cover and over-molding. We got these...

In Stock
[Buy Now](https://www.adafruit.com/product/4111)
[Related Guides to the Product](https://learn.adafruit.com/products/4111/guides)
### High Temperature Polyimide Tape - 1cm wide x 33 meter roll

[High Temperature Polyimide Tape - 1cm wide x 33 meter roll](https://www.adafruit.com/product/3057)
 **Polyimide Tape** (sometimes referred to by the brand name **Kapton Tape** ) is an interesting addition to your toolbox! Polyimide Tape remains stable across a wide range of temperatures&nbsp;from about −269°C to +400°C.&nbsp;Along with aircraft,...

In Stock
[Buy Now](https://www.adafruit.com/product/3057)
[Related Guides to the Product](https://learn.adafruit.com/products/3057/guides)

## Related Guides

- [3D Printed Case for Raspberry Pi Pico](https://learn.adafruit.com/raspberry-pi-pico-case.md)
- [Flapping Halloween Vampire Bat](https://learn.adafruit.com/flapping-halloween-vampire-bat.md)
- [DIY USB Cable Aviation Connector Retro-Fit](https://learn.adafruit.com/aviation-connector-diy-usb-cables.md)
- [ItsyBitsy ESP32 wFL case](https://learn.adafruit.com/itsybitsy-esp32-wfl-case.md)
- [TFT Gizmo Turtle](https://learn.adafruit.com/tft-gizmo-turtle.md)
- [PyPortal Discord Online Counter](https://learn.adafruit.com/pyportal-discord-online-count.md)
- [Numpad 4000 Mechanical Keyswitch Data Entry Device](https://learn.adafruit.com/numpad-4000-mechanical-keyswitch-data-entry-device.md)
- [Quickstart IoT - Raspberry Pi Pico RP2040 with WiFi ](https://learn.adafruit.com/quickstart-rp2040-pico-with-wifi-and-circuitpython.md)
- [NeoKey Emoji Keyboard](https://learn.adafruit.com/neokey-emoji-keyboard.md)
- [NES Emulator for RP2040 & RP2350 DVI Boards](https://learn.adafruit.com/nes-emulator-for-rp2040-dvi-boards.md)
- [PyGamer 3D Printed Snapfit Case](https://learn.adafruit.com/pygamer-snapfit-case.md)
- [NeoPixel LED Heart Necklace](https://learn.adafruit.com/neopixel-led-heart-necklace.md)
- [Infinite Text Adventure](https://learn.adafruit.com/infinite-text-adventure.md)
- [Wireless ESP32-S2 Touch Screen Controller for Pure Data](https://learn.adafruit.com/wireless-esp32-s2-controller-for-pure-data.md)
- [Monster Mask Case](https://learn.adafruit.com/monster-mask-case.md)
