Introduction: Hacking a USB Keyboard

Picture of Hacking a USB Keyboard

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

Step 1: Open Up the Keyboard

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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!

Picture of 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.


ThomY2 (author)2017-11-21

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

thing that worked was 2 arcade joysticks.

cspoelstra (author)2011-10-29

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 ?

harmono (author)cspoelstra2012-07-01

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.

cspoelstra (author)harmono2012-07-02


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


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


Trem4 made it! (author)2017-07-24

I did it, even though I managed to rip off 3 pads, everything works :D

I plan to make a glove "keyboard" with it.

ZabakK (author)2016-02-08

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.

GavinC27 (author)ZabakK2017-02-28

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.

JavierR49 made it! (author)2016-01-27

Hello randofo, I want to thank you for your ideas, by hacking a USB Keyboard I was able to build a DIY Taurus Moog Clone!!!!

Here's my project's blog (your post is referenced there).


holymoses (author)2015-10-07

...and what a handsome guy!


dstojanovic1 (author)2015-09-08

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.

Darknessblade. (author)2015-08-12

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

Jatin Goel (author)2015-08-06

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

SzabolcsK (author)2015-02-18

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.

ricardopalmieri made it! (author)2014-04-09

the main trick for was: fix all cables using hot-glue, sand a little bit the connectors on the board, and to solder, just keep the iron over the contacts and over the cable: just a quick touch with the solder metal and "voila"! after, i have fixed all the contacts with hot-glue, just to avoid mess. thank you by the tips!

thomkrauss (author)2011-06-08

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.

randofo (author)thomkrauss2011-06-08

Most keys cannot be pressed at the same time. There are a few exceptions though, which include 'shift', 'option' and 'control' (for example). You will need to experiment with the special function keys to get the ascii combinations that you need.

octopuscabbage (author)randofo2013-07-16

This is actually a limitation of those plastic sheets, if you wire directly to the controller you won't encounter this problem.

poita (author)randofo2011-06-18

Thank's dude that's an awesome instructable. I just found this site and haven't joined for full access yet so I copied andpasted it all into ms word.

I use a music playing program on my pc called 'HappyEO'. It let's me press mulitple keys at the same time to play chords etc.
On a related note. When I the program on some computers I get a delay when i press a key. I was using it on my 7 year old computer running XP and it was instant. When i installed it on my friends pc with windows 7 I got the delay from when I pressed a key to hearing the note. same on laptops running Vista and recently on a laptop runnin XP. Do you think it's something to do with the secrurity software that might be on the pc's?

thomkrauss (author)randofo2011-06-08

Well I got lucky! I was able to tweak the free program that I'm going to use to produce the drum sounds. I was able to record the sound of the kick and crash together on a free audio recording program and then save as a wav file and map a keyboard character to that new recorded sound. I'll then just connect my button to that new letter.
Thanks for giving me the need to keep looking for an answer!

harmono (author)thomkrauss2012-07-01

You can type multiple keys at one time, but it has limitations. Some key combinations will not work. If you are doing simple drum patterns it might work if you tested different combinations of keys. I have tried playing 3 note polyphony, and it works to a certain extent, so yes it can play polyphony, but it's tricky.
What you should do is download MAX/MSP, the demo version, and try programming it to play drums with your keyboard. Then when you have found the keys that work together, you can use those. Let me know if you need help. I can help you with the MAX/MSP, and I can help you with hacking the keyboard, done both. I'm still learning about the keyboard hack. Your drum project is fairly straightforward, and can be done with MAX/MSP.

baneat (author)2012-12-29

Very impressive modification.

electronic boy (author)2008-08-13

i have a usb keyboard and have tried to solder wires on but the contacts are like half a millimeter apart i am using a 12 watt soldering iron and i am neat at soldering

harmono (author)electronic boy2012-07-01

Try this. Drill tiny holes in a piece of wood, or plastic. Or if you have access to a laser cutter cut holes in acrylic. That's how I did it. Let me know if you need help.

Try using just a little less solder. I've found that to be very useful.

Thank,s it worked very well and i went on to mod a wireless one and made a controller

joearkay (author)2009-09-08

what is the prime use for this?

harmono (author)joearkay2012-07-01

There are many things you can do. You can make your own video game controller keyboard, or make an ergonomic keyboard. Experimentation with different ways of inputting keys. Or even make a musical instrument. My motivation was to make a musical instrument.

dagob (author)joearkay2012-06-30


harmono (author)2012-07-01

I am in the process of hacking a keyboard. The key layout looks similar to the grid, so they might be fairly standardized. Unfortunately I need lost more variety, so I am going to have to make a grid that includes things like Page Up, Page Down.
I created a special jig from acrylic using a laser cutter. I needed something to hold the wires in place, because I wanted to solder them all at one time. That didn't work, so I'm going to try a different approach. I want to be able to repeat this multiple times. I used a grey computer ribbon cable and soldered the wires directly to the board. The gray ribbon cable then goes to a connector that connects to a veroboard. Then I soldered rainbow wire to the veroboard. That's where I am right now. I'm going to use VB.NET or MAX/MSP to help me map the keys, because I need to see how the circuit works. Tracing the connections only shows what is there by design, I want to know how it all works. If you are interested in perhaps more information, in the way of an instructable or other way, reply, or let me know.

tedino (author)2012-02-07

That video u mentioned on is down due of Inactivity. Please send new video and url please.

This was good tutorial :) i wanna see that video and i wanna try making own version of Typewriter perhaps :) Need motivation and wanna see that video :)

vikingberserker (author)2011-08-26

BRILLIANT!! Thank you, you have no idea how much this one helped me!

thomkrauss (author)2011-06-02

Is it safe to say that I should only use each pin once, to keep the wires and the board free of excess solder? I'm trying to use this method to build a set of drum triggers, an entire kit of drum pads, and want to know how many inputs I would end up with. The more I can get the better, I just want to see how limited I would be. I guess I could use two keyboards if it really came down to it.
Also, will a piezo attached to these pins work and will it produce two "keystrokes" for each hit as I've seen mentioned?
Thanks for the great instructions, and thanks to all who contribute and answer all the questions out here.

randofo (author)thomkrauss2011-06-02

You would use each pin once, but you can then connect the wires to another circuit board where you can connect multiple wires to each one. By doing that, in theory you can get the full keyboard. See the mess of wires here:

thomkrauss (author)randofo2011-06-02

ok then my next question: if I were to connect multiple female RCA jacks to 2 pins on the board (to enable the "shorted connection" and "type letters") and then at the other end took a button and connected that to a female RCA jack and used male to male RCA cords to connect the junction boxes I make, will pushing the button make a connection and "type letters" or is there too much wiring going on?

randofo (author)thomkrauss2011-06-02

Sounds reasonable.

smoak (author)2011-05-12

I'm trying to put this into a custom controller. Simply using 12 keys, random if need be. Which side is side A and which is side B. My guess is that the top layer is side A and bottom later is side B. Would I be right to assume this? I'm hoping it would save me the trouble of having to trace, I have terrible eyes.

dimitrisa10 (author)2011-04-04

what will happen if you connect three pins will it display 2 characters because i'm making a hand-top out of a pico itx board and im wondering if i can use this to make a thumb keyboard

randofo (author)dimitrisa102011-04-04

If it is a function key or the shift key or something like that, it might do something. Most likely, it will not do anything (or nothing you would want it to do). It won't make two characters.

dimitrisa10 (author)randofo2011-04-07

thx for the info do you think it would work though for a tiny keyboard

currently_awake (author)2011-01-05

keyboards send two scan codes for each key hit. One for each key press, a second for the key release. (the second has a bit set to mark it as a release). All the keys on the keyboard work this way, even shift and control.

snag46ed (author)2010-10-21

Great Instructable! I'm a little confused though. So all we need to do is wrap the wire around to the corresponding pins and GLUE them down, or SOLDER, or does it matter?

Also, I'm trying to build one with one simple function...I want to make a big "Easy" button, or something like an "Easy" button send a space bar input. Would I follow the steps in this instructable, connect the "free" side of the wires from the modded keyboard controller to a prototype breadboard, and connect the leads of the Easy button to the breadboard where the wires from the keyboard connect?

So basically keyboard controller -> Prototype breadboard <-Easy button...?

Thanks so much!

snag46ed (author)snag46ed2010-10-21

I'm kind of a noob when it comes to hacking electronics, fyi :)

thealeks (author)2010-09-06

very nice instructable! im about half way thru hacking a keyboard of my own and this has helped me immensly! my hack is a little different tho. ill post an instructable soon!

capth00k (author)2010-06-25

I tried to make this hack work with an old PS2 keyboard I had laying around -- to paint the keys on it and use as a synth controller on my mac - even got the PS2 to USB wiring worked out but it lights up and doesn't allow me to input characters ; nor is is recognized as a USB keyboard. I think there may be a USB device controller that PS2 boards doesn't have ; so perhaps changing the first page 'USB or (any) keyboard can be converted' should be changed if there isn't any way to make a PS2 one work. Here's the controller I pulled out of the old PS2 dell quietkey : The PCB is 123452 REV J ; the large IC has the following markings: nmbk15r4286 std5a8d bh 124200-002

Lee Wilkerson (author)capth00k2010-09-03

You are absolutely right about the USB device controller. All USB devices have controller chips - that's how the OS recognizes that a USB device has been connected. ~/Lee

I MAKE STUFF (author)2010-08-25

another use of this is to add switches to flight sims such as fsx, fs2004 ect.

jibatsu (author)2010-08-05

on my keyboard, multiple keys are on the same pin e.g. the left key and the enter key, do i solder double wires onto the pins to connect to 2 keys. will they both work independently?

randofo (author)jibatsu2010-08-05

Yes, multiple keys will be on the same pin. The key presses are created by connecting different pairs together. So, for example, one pin on "Side A" might connect to eight other keys on "Side B" to make eight different key presses.

jibatsu (author)randofo2010-08-05

so i only have 1 wire to each contact. amirite?

About This Instructable




Bio: My name is Randy and I am a Community Manager in these here parts. In a previously life I had founded and run the Instructables ... More »
More by randofo:Large Motor ProjectsRemove a Wheelchair Motor BrakeBuild a Robot
Add instructable to: