How to create custom shortcut keys with Arduino

You're still pressing buttons, but like, not as many.

If you spend a lot of time at your computer, there are a variety of tasks you perform over and over. Common functions such as copying and pasting can be sped up with shortcuts—Ctrl+c and Ctrl+v on Windows—but other commands aren’t well-known, or require finger contortions that seem impossible.

One option for making your computer-bound life a tiny bit easier is a custom shortcut keyboard made with an Arduino-compatible microcontroller board like the Pro Micro.

This little board is capable of emulating a human interface device, or HID, based on sensor inputs or button presses, so you can use it to replicate the function of a keyboard or mouse. Not all microcontroller boards can do this, but those that can will let you copy and paste text or start and stop your favorite background music without moving your hand all over your desk.

In addition to a microcontroller board, you’ll need:

Arduino shortcut keyboard setup
When you've completed the project, it should look like this.Jeremy S. Cook

You could even do away with the breadboard and just solder the buttons to your microcontroller, but it’s better to keep it, as making connections will be much easier.

Solder the headers (these look like rows of pins, and are likely included) on your microcontroller board, then plug it into the breadboard, straddling the channel in the middle. Plug the two buttons into the breadboard the same way.

Strip wires as necessary, then connect them to breadboard holes next to pins labeled 2 and 3, and plug the other end of each wire in next to each button’s nearest connector.

Link the other side of each button to any spot in the breadboard’s column of negative connectors, then run a final wire from the negative column to the microcontroller board’s grounding pin (GND). Refer to the photo above if you run into trouble.

Now, when you press a button, it'll connect either pin 2 or 3 to ground (the negative column), signaling it to perform an action. To complete the project, copy and load this example file into your microcontroller using the Arduino IDE. When you do, select "Arduino Leonardo" as the board, along with the proper communication (COM) port. Once the file is on your microcontroller, your computer will recognize your creation as a HID and you'll be able to play or pause media with the push of a button.

If you'd like to control volume in the same manner, download and install this code from my GitHub page. Instead of playing and pausing media, it'll let you control your computer's volume via the two buttons on the breadboard.

This is, of course, just the beginning of what you can do with this type of custom interface. More buttons, or even sliders and rotary inputs, can be used to add more shortcut keys, or could allow you to adjust speaker volume or other settings by twisting a knob as you would with a radio. One could even attach a motion sensor to such a setup and use it to, for instance, wake your computer up when you walk in the room.