Keyboard Shortcuts Using Arduino




I love keyboard short cuts, but hate having to look down at the keyboard to locate the appropriate keys. And sometimes I forget which keys I need to push for my shortcut to work. Should I have pressed Alt along with Page or should it have been Control?

And why press two keys, can’t I just press one key to do what I want?

I looked around for a keyboard with extra keys that were programmable but there are only a few, and the ones that I saw were about $150, so I decided to try to build my own. I only paid $9.90 for the Leonardo and $4.00 for the Mini so the whole project was only about $15!

Step 1: Parts List

Arduino Leonardo

Arduino Mini or full size Arduino such as a Uno if you like

About 600 mm or 2 feet of 4 core cable

Some thumb tacks (These are the keys)

1 x 1 MegOhm resistor for each button you need

1 x 100mm or 4 inches of wire for each button you need

1 x 50mm or 2 inches of wire

A small enclose to house your Uno and wiring (I used an Arduino Mini so housed mine in a small block of wood)

A cable clip

A “Proto Board” or a bit of perf board

Step 2: Circuit Diagram

Step 3: Prepare Your Housing

Depending on the housing that you are using, I will leave
that part up to you but here is what I did. I cut a piece out of one end of my piece of wood to fit in a Pro Mini, wiring and resistors.

Step 4:

On the underside, I cut some grooves with a router to fit
the wires.

Step 5:

I marked out and drilled some small holes for the button
wires to push through.

Step 6: The Wiring

Solder the short lengths of wire to each thumb tack.

Step 7:

I covered the top side of the wood with some contact paper
and pushed the wire and thumb tacks into the holes drilled earlier. I pulled the wires tight in the grooves and covered the bottom of the wood with contact paper.

Step 8:

Solder the resistors to the other ends of the wire as in the

Step 9:

Join all of the ends of the resistors and solder to another
short length of wire like this.

Step 10:

Solder the lose wire (the one that is soldered to all of the
resistors) into Digital 4 on the Arduino and solder other ends of the resistors into their appropriate holes. Digital 4 is the only one that has to be soldered in the right place. If you find later that you have some of the other wires wrong, don’t worry, you can rearrange them in the code.

Step 11:

Solder some header pins to the bottom of the proto board.
You only need 4 but I added the others for a bit of stability. I secured the cable to the board with a couple of bits of wire.

Step 12:

Step 13: The Code

My Keypad sketch is a modification of Paul Badger's
CapitiveSense Library Demo Sketch.

I decided to use SoftwareSerial on digital pins 10 & 11 on the Pro mini. That leaves 0 & 1 free so that I can connect a FTDI programmer to those pins later for reflashing the board if needed.

There are lots of comments in the code.

Step 14: What to Do Next

Add more buttons for more short cuts.

Attach a small speaker to the Leonardo to give you an audio feedback that you have copied something.

Put a small cell phone vibrating motor in the keypad to give you haptic feedback.

I have the Leonardo on a short micro USB lead plugged in to the USB hub and about two feet of lead going over to the keypad. You could experiment by doing away with the Pro Mini and putting the resistors on the Leonardo and have long wires running to the keypad and onto the thumb tacks.



    • Cardboard Challenge

      Cardboard Challenge
    • Safe and Secure Challenge

      Safe and Secure Challenge
    • Comfort Food Challenge

      Comfort Food Challenge

    12 Discussions


    3 years ago on Introduction

    How is it possible to run this on only the Leonardo and printing letters instead of commands?


    4 years ago on Introduction

    I''m tring to make one of these for school that only needs one aurdino and only presses two keys (Windows Button and L) at the same time. Any recomendations?


    Reply 4 years ago on Introduction

    "You could experiment by doing away with the Pro Mini and putting the resistors on the Leonardo and have long wires running to the keypad and onto the thumb tacks."

    nope, only one is necessary, He just used 2 for simplicity in this case. I belive the uno can act as a keyboard cant it? If so, then yeh, this would work with the uno, but might need a few code mods...


    Reply 4 years ago on Introduction

    Nope. Unos dont work as it. Take a Dua (or as i suggest) the cheap Micro.

    I am using a micro for a 7x6-Keypad fully programmable (on the fly) over emulated USB-serial. As buttons i use peizo discs with a bit of added circuitry.


    Reply 4 years ago on Introduction

    Hi Orngrimm,

    could you let me know, how you attached 42 Keys to a micro as it has just 27 Pins?

    I´m new to the Arduinos and maybe its a dumb question. Would be nice if you can lead me to a tutorial or any other Information.

    Thx :)


    Reply 4 years ago on Introduction

    No such thing as dumb question! :)
    The trick is to use them in a matrix-configuration. Sounds complex, but isnt:

    - You have columns and rows. in my case 7 columns and 6 rows.

    - Every switch "sits" on a junction of a row and a column and connects them if pressed.

    - Now you simply set one column on high and check if and which row goes high. Lets say the 4th row goes high. Then you knwo: The 4th button on the 1st column is pressed.

    - Now you go to column 2 and repeat the scan for this line. Lets say that no row goes high: You know: No button on the 2nd column is pressed...

    - 3rd column...


    - 7th column.

    with such a matrix-method you can scan a total ammount of [rows] TIMES [columns] by using a total number of pins [rows] PLUS [columns]. In our case (7*6) i can scan for 42 buttons (7*6) by using only 13 pins (7+6).

    See for a nice graphic of a 4*4-matrix


    Reply 4 years ago on Introduction

    THX a lot. This should work for capacitive Buttons too I guess. I'll check that :)


    Reply 4 years ago on Introduction

    Yes. Matrix-Style also works for capacitive buttons. But you have to be carefull in the capacitance and resistance you have within the row- and Column-Switches: If they have too uch capacitance, oyu may have troubles in reading them correctly. Use high-Quality-FETs with very low capacitance or even use old fashioned relais :)


    Reply 4 years ago on Introduction

    Hi Brinth and Dan

    The Arduino website says that only the Leonardo and Leonardo Micro are capable of sending keyboard codes. I tried using my Uno, but when you select Uno as your board in the Arduino IDE, you get "Keyboard was not declared in this scope" when you try to compile the code.

    Yes it does work if you connect the resistors straight into the Leonardo. My wires when testing were about 3 feet long. I found that when touching the outside of these wires I was affecting the capacitance, that is why I set the sensitivity quite high to 800, so that I wouldn't get false triggers. Another issue is that you need one wire for each switch so if you want 6 switches you would need 6 wires.


    Reply 4 years ago on Introduction

    The Uno is not capable of emulating a USB-HID-keyboard on its own. It can be done, but needs a reflash of the Bootloader of your arduino. You dont want to do that since it would render the cool arduino-features null.

    The Arduinos with Atmel32U4 can do it out-of-the-box like the Leonardo, Micro, and Due. the Tre (as soon as it comes out) will also have this feature.
    Also the Yun should work but havent tried it.


    4 years ago on Introduction

    Every Arduino with a Atmel 32U4 can do it in a single package like the Arduino Leonardo, Micro, and Due. The micro is of special intzerest since it has more than enough digital-ports to scan for a plethora of keys (if you do a matrix) and is cheap as hell (around 5$. free shipping from china).

    Just scan the key, then use the sketach at to do it.

    the use of 2 arduinos for this (one for scanning, one for translating into USB-HID-Keyboard) is a bit over the top i think. But it works. So kudos on this cool project! :)