Hacking a USB Keyboard




Introduction: Hacking a USB Keyboard

About: My name is Randy and I am a Community Manager in these here parts. In a previous life I had founded and run the Instructables Design Studio (RIP) @ Autodesk's Pier 9 Technology Center. I'm also the author of …

How to hack a USB keyboard or any keyboard for that matter. Send inputs into the computer without a pesky microcontroller.


You will need:

A USB Keyboard

Step 1: Open Up the Keyboard

Open up the case. You can use a screwdriver or an any ridiculous looking multi-purpose tool. Sometimes even after all the screws are removed the keyboard still won't open up. In this situation, don't worry, just forcefully pry the case apart with your screwdriver. It doesn't matter if you break the case. You don't really need it.

Step 2: Trace the Letters Back to the Pins

The inside of the case should have two plastic sheets (one on top of the other). One plastic sheet will have printed conductive tracings that go to one set of pins on the circuit board and the other sheet will have tracings that go to another set of pins on the circuit board.

When you press down on a key, the tracings on both sheets will touch each other. This completes the circuit and tells the board to send a letter, number or command back to the computer.

What you need to do is to label each conductive circle on both sheets with the letter key that corresponds to it. So, for instance, if you were to press down "A" on the keyboard, label the plastic circle on both sheets of plastic that would be pushed together if the "A" key would strike (see picture of labeled sheets).

Once you have labeled both plastic sheets with all of the corresponding keys (that you plan to use in your project), the next thing you need to do is to trace the letters back to the circuit board with a Sharpie (see notes on pictures).

One way to simplify the matter is to consider one sheet "SIDE A" and the other "SIDE B" .

Below is a chart that I made for the particular keyboard I was working on. Please remember that all keyboards are different. It will help you immensely if you make a similar chart for the keyboard you are working on.


| | | | | | | | XXXXXX | | X | | | | | | | | X
1234 5678 12 11 10 98765 432 1



A01 - 0, 9, 8, 7, 4, 3, 2, 1
A02 - 6, 5, -
A03 - N, B, ?(slash)
A04 - (period), (comma), M, V, C, X, Z, (enter)
A05 - H, G, (space), '
A06 - L, K, J, F, D, S, A, ;
A07 - Y, T
A08 - P, O, I, U, R, E, W, Q


A02 - 1, Q, A, Z
A03 - 2, W, S, X
A04 - 3, E, D, C
A05 - 4, 5, R, T, F, G, V, B
A06 - 6, 7, Y, U, H, J, N, M
A07 - 8, I, K, (comma)
A08 - 9, O, L, (period)
A09 - P, 0, ?, -, ', ;
A11 - (enter)
A12 - (space)

Step 3: A Note on Pin Layouts and Shift Registers

Basically a keyboard is a specialized shift register. It takes in a lot of inputs and sends out one output to the computer (that being a an ASCII code or control command).

When a switch is closed, the shift register processes which two pins are connected and interprets it as one particular output.

So, if you had ten pins going to each plastic sheet, then you would have one-hundred possible combinations. This is because every single pin on one sheet can be comined with every single pin on the other side. This would produce ten rows of ten possible combinations. In other words, you have just produced a "10 X 10" 2-dimensional array.

For instance, if you connect "Pin 4" on SIDE A and "Pin 6" on SIDE B you will produce the letter "M" on the computer (see picture).

If you connect "Pin 8" on SIDE A and "Pin 7" on SIDE B you will produce the letter "I" on the computer (see picture).

It's really quite simple.

Step 4: Attaching Wires

So, now you know which pins produce which letters. Now you need to connect your own mad creations to the boards.

But wait!

Before you can connect things to the board, you need to connect wires to the board!


You're going to need:

wire (ideally in a number of colors)
quick setting epoxy (from your local Radioshack or Home Depot)
a razor blade
a soldering iron

So, here is what you do. Count the number of pins you need to attach wires to. Once this is done, prepare all of the wires you're going to need. They need to be stripped on both ends about a quarter of an inch and should be about five to six inches in length. Try to use many different colors of wire so you can tell them apart later. On one end, bend the stripped part of the wire so that it can hold itself to the board (see picture).

Wrap the wire around the board so that the stripped part is touching one and only one of the pins that it needs to be connected to. Make sure none of the wires are touching. When all of the wires are in place (touching the pins and not touching each other), you're going to need to glue.

Prepare some epoxy and cover the back side of the board in epoxy so that the wires are glued in place on the side opposite from the conductive pins. Leave it for how ever many hours the epoxy says it needs to sit for for maximum strength.

Sixteen to twenty hours later or so, you're going to need to solder. So, solder the wire to the pin. If the solder won't stick to the pin, scratch the pin with a razor blade a couple of times and try again. If the pin is coated with something, scrape off the coating with a razor blade and then solder to it.

If you have a lot of money, just glue the wire to the pin with conductive epoxy very, very, carefully.

When everything is dry and in place, test the keyboard. If it works, then you're more less done.

Put it in a nice case or put it in a radioshack case. It doesn't matter.

Step 5: Other Keyboards and Considerations

Some keyboards have sockets. If it does, it saves you a lot of work. What you need to do is get your own socket or set of header pins and solder wires to each connection. Once you have a socket or header pins with wires attached, plug it into the socket on the board. Test it to see if it works by touching a wire on each side together. If it works, glue the header pins or socket into the socket on the board and you're done. It's so simple to connect, in fact, that you may not even want to bother tracing the plastic sheets and just try to figure out the key combinations by trial and error.

Also, there are Mac USB keyboards that allow you to connect other USB devices to the computer through them. I wish I could tell you something more enlightening about the USB connections on those boards, but I can't. Maybe you can do something profound with them. Otherwise, you can just attach wires to it using the method shown in Step 4.

other considerations:

-The USB cable has a tendency to rip off the shift register board. You may want to glue it in place.
-USB devices are 5v 100ma
-Some boards have LEDS attached (see picture). You may be able to send data back from the computer to light them up. If you can control the LEDS, then you can attach low voltage relays to them and have outputs as well as inputs. I haven't tried to figure it out yet, but if you want to give it a go, a good place to start may be here:


Step 6: One Step Beyond!

Once you have a hacked keyboard you can use it for a number of functions and attach a number of different types of switches.

You can build your own typewriter keyboard. Check the picture and video. It may not auto-load and it may take a long time to load when it does (it's around 20 MB), but here is the video of the typewriter:


You can use a photocell as a switch (as seen in the picture and video).

You can hook it up to a capacitance sensor and use just about anything to trigger an event in a Flash movie.

You can hook it up to some floor switches and develop your own DDR game.

You can do more things than I could ever dream up.

Did you find this useful, fun, or entertaining?
Follow @madeineuphoria to see my latest projects.

4 People Made This Project!


  • Build a Tool Contest

    Build a Tool Contest
  • Make It Modular: Student Design Challenge

    Make It Modular: Student Design Challenge
  • Digital Fabrication Student Design Challenge

    Digital Fabrication Student Design Challenge



9 months ago

Every USB keyboard has an embedded micro-controller that stores the current state of the keyboard in flash memory. The cycles are there at all times, waiting to be accessed. Normally, the controller is read-only so you can't modify it or use it for anything useful. But this was not done with security in mind... It's just supposed to prevent random people from being able to fiddle around with your device doing things you might not intend. and make sure they are functional via these amazing sites keyboardchecker.com, https://joltfly.com/keyboard-test/
or https://www.keyboardtester.com
But if your USB keyboard is running on battery power or through a wall plug power adapter then how does that work? Isn't this too indirect of a connection? Well, no. Remember that powered hubs have their own DC/DC converters

Le Struggles -x-
Le Struggles -x-

Question 1 year ago

I have a similar question as the user Dhklll, but more different. I’m trying to hook up a piezo speaker to a usb keyboard (maybe use an Arduino UNO, if needed) in a way that will produce a vibrations for a short time and/or few seconds (Morse code to be exact). How would I program each key to vibrate in Morse code? What board will I need to use or add on? Ex) if press “A” key then “• —”


1 year ago


I unfortunately have no new idea.

The keyboard always derails, I suppose by marking inopportune characters.
The pad and the mouse?

Debris causing accidental random contact at the electrical level (and inaccessible) of a key?
Not impossible.
Try to press firmly (without exaggerating ...) a few seconds all the keys one after the other. This may be enough to crush debris between the electrical contacts.

Try with:
to identify the key (s) with the problem.

Another possibility would be a failure of the keyboard management circuit. Effect of electrostatic discharge from the cloth?

Another way:
Start the BIOS / UEFI SETUP or start an OS (Linux, ...) with a live CD.
See if the problem appears under these circumstances
If the problem goes away like this, the hard disk with Windows has a faulty parameter.

There is the mouse mode (or Mouse keys) which is activated when you press a key for a long time.
The symptoms have clear similarities with this mode, but this mode is normally deactivated on reboot.
Wouldn't the 'normally' have been respected?
Or would it be nested with something else?


3 years ago

How I can connect a small speaker so when I type on the keyboard it's says the letter ?
Please can you add tips and tricks?


Reply 3 years ago

That is not really a problem solved by this Instructable.

The way I think you would want to do it is to plug it into a Raspberry Pi, and have it run a script which reads out loud the keypresses using pre-recorded audio. And then, the script (pretends to be a keyboard) and exports a keystroke command on to the next computer (assuming you ultimately want to show this on a computer screen).

You could also take a similar approach with an Arduino, but it may be a little trickier and require some additional hardware.


Tip 3 years ago

Excellent article. Could you do you a favour mate - I've attached A USB keyboard to my Mac and came to this site looking for a square root symbol - I Was seeking the ASCII map.

Any help would be much created as I'm writing a research paper to try to solve the financial problems of the planter - if 1=1 then 2=2 ad infinitum. The solution I'm aim at is 1:1. Over and out ;-)


4 years ago

I tried this over and over and cannot get it to work consistantly, lst attempt theonly

thing that worked was 2 arcade joysticks.


10 years ago on Step 3

Thanx man, I was wondering for a wile to make such a thing as a cheap replacement for a midi controller for my DJ setup.. How about the switches you can use, is there an resistance problem ?


Reply 10 years ago on Introduction

I'm just curious. What kind of control did you need? Do you play chords, use arpeggiators, or use midi controller to enter notes, or are you talking about sending control messages? I'm not sure how a keyboard could help with that. I am using MAX/MSP in my project, and I'm entering chords and outputting MIDI from MAX/MSP.


Reply 10 years ago on Introduction


I was looking for something I could use besides my mixer and CDJ's thad can control effect of just navigation through the software I use on my laptop.
I've made a system pretty much the same as you described adding some momentarily buttons and some switches. (I'll send a picture whit the massage) It was originally mend to be used as some kind of prototype so if I liked it I could change the electronics...but I did quit some gigs whit it now and it seems to hold up so far :P

2012-01-25 19.03.58.jpg2012-01-25 19.04.08.jpg2012-03-23 16.19.27.jpg2012-04-25 11.55.47.jpgIMG_7642.JPGIMG_7644.JPGIMG_7652.JPG2012-04-26 01.37.26.jpg

Reply 4 years ago


Clean and Nicely done cspoelstra ! Can we see it in action ? Thanks :-)



6 years ago

I've done this independently couple of times. Here are some tricks: Use soft wire to solder it to the board and after soldering it to the pins, use hot glue to secure it in place.

The tracing of the sheet lines can be difficult and boring and prone to errors, most keyboards usually split the pins into two A and B section where the pin from A part connect to the one of the pin in B section so I just plug the USB, fire up a keyboard to screen app and then use wire to shorten pin from A section with pins from B section one by one then note the corresponding ASCII on paper.


Reply 5 years ago

what a time saver! I looked at the wiring sheet and thought it was impossible to follow the lines to the pins. Your method was a lot easier.


6 years ago

...and what a handsome guy!



6 years ago on Introduction

Nice hack. I made this a couple years ago and connect with foot switch from panic alarm pedal. That way I made distortion pedal switch for Amplitube. I have a bunch of ideas for this hack but I don't have time for realization.

Wish you luck in future projects.

the 1980 keyboards are much better since they have a whole circuitboard over the keyboard

Jatin Goel
Jatin Goel

6 years ago on Introduction

good one but in need more output pins also so please tell me more


7 years ago on Step 3

I want to control a MIDI host this way. Just borrowed a worn out USB keyboard from my buddy and i will hook it up to a cheap toy synths keyboard.


11 years ago on Introduction

So another question...
Basically I'm using this hack to control an electronic drum set that I'm trying to make using the alphabet characters as triggers. The program I'm going to use seems to allow simultaneous hits.
My question: How do I wire it so that one button will trigger two different letters at the same time? My thinking is that if I wire two letters together, the board will be confused, this sending the wrong signal or no signal at all.
Can anyone explain what should happen? I'd like to address this before I try to build this and see that it doesn't work.