Вы находитесь на странице: 1из 13

Home Sign Up!

Browse Community Submit


All Art Craft Food Games Green Home Kids Life Music Offbeat Outdoors Pets Photo Ride Science Tech

Hacking a USB Keyboard


by randofo on April 19, 2006 Table of Contents Hacking a USB Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro: Hacking a USB Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 1: Open up the keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 2: Trace the letters back to the pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 3: A note on pin layouts and shift registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 4: Attaching wires . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 5: Other keyboards and considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 6: One step beyond! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 2 2 4 5 7 8 9 9

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

Author:randofo

Randy Sarafan loves you! I am the author of the book '62 Projects to Make with a Dead Computer' and Community Manager here at Instructables. I'm always sharing tons of awesome projects. Subscribing to me = fun and excitement!

Intro: 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


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.

PIN LAYOUT:

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

| | | | | | | | XXXXXX | | X | | | | | | | | X 1234 5678 12 11 10 98765 432 1 SIDE A SIDE B PIN SIDE A 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 PIN SIDE B 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)

Image Notes 1. Where plastic sheets connect to the pins on the board.

Image Notes 1. Pin SIDE B... 1 through whatever... from right to left.

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

Image Notes 1. Pin SIDE A.... 1 through 8... from left to right

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" 2dimensional 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.

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

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! Sigh... 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.

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

Image Notes 1. Don't let your USB cable rip off like this one did. It would be a good idea to make a note of which colors connect to the board where as in the next picture.

Image Notes 1. bend your wires like this and then slide them over the edge of the board so it connects to the pin.

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

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: http://www.beyondlogic.org/keyboard/keybrd.htm

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

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: http://a.parsons.edu/~randy/video/typewriter.mov 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.

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

Related Instructables

Protect Yourself Against This Popular Hack: Hardware Keyloggers by Revolutionaries

Easy Button Musical Interface by jro

DOUBLE KEYBOARD by fi5e

How to Make an Auto-Hacking USB Drive by Crazy Leprecaun

Honey I shrunk the Keyboard by s0845

Hack your usb missile launcher into an "Autoaiming autoturret!" by toelle

Comments
50 comments Add Comment view all 144 comments

currently_awake says:

Jan 5, 2011. 6:01 PM REPLY 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. Oct 21, 2010. 12:47 PM REPLY 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 says:

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

Oct 21, 2010. 12:48 PM REPLY

thealeks says:

Sep 6, 2010. 3:18 PM REPLY 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! Jun 25, 2010. 6:36 PM REPLY 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

capth00k says:

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

Lee Wilkerson says:

Sep 3, 2010. 7:05 AM REPLY 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 says:


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

Aug 25, 2010. 6:18 PM REPLY

jibatsu says:

Aug 5, 2010. 6:09 AM REPLY 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 says:

Aug 5, 2010. 7:59 AM REPLY 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 says:
so i only have 1 wire to each contact. amirite?

Aug 5, 2010. 8:54 AM REPLY

randofo says:

Aug 5, 2010. 10:20 AM REPLY Yes, but you would want to connect that 1 wire to each switch that you are looking to add. So, if left and enter go to the same pin, that 1 wire would connect to both the left and enter buttons. Aug 5, 2010. 9:00 AM REPLY all i need is L shift, S, enter, left, up ,down, num enter, num +, num - i followed the tacks back to the pins and marked them, how do i then wire it up as i have more buttons than pins.

jibatsu says:

KarateLover21 says:
I am hoping to make a controller for scratch. I am making arrow keys, ZXCV and space.

Aug 3, 2010. 9:18 AM REPLY

DackMilk says:

Mar 1, 2010. 4:13 AM REPLY HOW ARE THE "ALT" AND "SHIFT" KEYS IMPLEMENTED? THESE SIGNALS ARE NOT SEEN BY MY COMPUTER IN ANY WAY BUT PRESSING THE GOD DAMN SHEETS OF PLASTIC TOGETHER!!!

Fuingurth says:
well apparently, the CAPS LOCK key IS recognized

Jul 22, 2010. 2:44 PM REPLY

electronic boy says:

Aug 13, 2008. 5:52 AM REPLY 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

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

Jun 30, 2010. 8:02 PM REPLY

electronic boy says:


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

Jul 4, 2010. 7:46 AM REPLY

hacker3455 says:
Is there any visual way to tell if you fried your keyboard PCB?

Mar 30, 2010. 12:17 PM REPLY

randofo says:
It stops inputting letters into the computer.

Mar 31, 2010. 9:41 PM REPLY

hacker3455 says:

Mar 31, 2010. 10:10 PM REPLY well i know thats not working, just wondering any dis-coloration in the board or something to that extent that would be an indicator. Guess i need to get a cooler soldering iron and a new keyboard.

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

xM4ST3R SHAKEx says:


is that the way you read the pins on side b? right to left?

Feb 18, 2010. 12:54 PM REPLY

denis10k says:

Jan 25, 2010. 4:37 AM REPLY A very easy way to find out which pin goes to which button: Put one of the layers on a image scanner, scan it and fill the lines with different colors using the fill tool. Took me only 30 minutes to get the entire pin layout Dec 22, 2009. 11:25 AM REPLY Insane. I had absolutely no idea that a keyboard's guts were so simplistic. I've created numerous toys/devices and have always been lacking for a way to design my own input method that didn't involve some complex crap with an arduino<sp?> device or something. My latest attempt was going to be a large MAME machine, but I was scratching my head on just how to deal with the inputs. Trying to stick a full-blown keyboard into the device just to have the buttons press the keys seemed a bit hacky at best. This is awesome. Now I'm just TRYING to figure out what all I want to make with my extra keyboards. I even have some wireless keyboards that I could see using to do some fun stuff with.

Javin007 says:

ratgod says:

Oct 16, 2009. 8:56 PM REPLY I've had a similar idea, I was going to use an old PS/2 style keyboard as an arcade joystick interface, I have the board out and mapped the keys (I shorted the sequences while plugged into an old laptop, but your way seems much better). I was going to build a MAME cabinet using it, but never got round to it. very good instructable.

rickharris says:

Sep 6, 2009. 7:44 AM REPLY Hi, I want to control my PC via the keyboard from an external microprocessor - My thought is to simply bridge the keys I want to use with a 4016 quad switch. Did you try this?

bassbindevil says:

Sep 13, 2009. 10:10 PM REPLY That should work. Or there are some general-purpose USB chips. Off the shelf things like the IOWarrior, the "CREATE USB Inteface", one at Madhacker.org. http://www.madhacker.org/usb_hid_keys.htm Another option is to look out for old USB specialized game controllers, or a USB gamepad. That may be more straightforward than going with dualling keyboards. I've run into various game controller gizmos at thrift stores, like the Nostromo Speedpad from Belkin, something called "The Claw", and a Microsoft thing intended for strategy games. The "The Claw" is almost ideal... it's just a USB microcontroller wired to a bunch of switches. Alternatively, don't overlook the analog joystick port... it supports several switch inputs. Even the analog inputs can be used: switch different resistor values across them. This allows multiple inputs using a single wire (plus ground). And finally, there's the parallel port; searching will turn up ways to use that for input and output. If you need software, Girder will accept a wide variety of input devices using plug-ins. Some older versions were freeware (or at least didn't expire when unregistered). http://www.promixis.com/girder.php

exabopper says:

Sep 12, 2009. 9:51 PM REPLY I've been wanting to try this for months. There are many MIDI programs that will take input from your keyboard as if it were a piano, but of course playing your keyboard is almost impossible unless you custom-label the keys. Now, all you need is your hacked keyboard and a kid's toy keyboard from a toyshop, a little wiring, and you have an effective MIDI instrument! Thanx!

bassbindevil says:

Sep 13, 2009. 9:39 PM REPLY Look out for scrapped electronic organs. Keyboard quality has to be better than a toy. Other options: leave the case intact, use all the keys, switches, pedals, and use the internal speaker and amplifier if it still works.

king_grimloc says:

Sep 12, 2009. 9:11 AM REPLY I did something very similar to this with a Commodore 64 I had that I modified to use a Mini-ITX motherboard. I ended up making a PC board that replaced the original one and routed all of the keys to mach the keyboards controller from a $10 keyboard I purchased for this purpose. The only thing I can say is that the PC board the controller is on is not usually very sturdy, so it won't take a lot of heat from your soldering pencil. You will also want to re-enforce the wires with silicone RTV. Sep 12, 2009. 8:06 AM REPLY Very interesting.....and since they toss keyboards on a regular basis at work, I can have a field day and not fear harming a good one :-) Most of the time, users eat too many pretzels, chips and cookies over their keyboards, and eventually they just stop working altogether. . .

Goodhart says:

avibank911 says:
how do you solder the wires without burning the PCB??

Feb 2, 2009. 8:19 AM REPLY

Azayles says:
Use a soldering iron, not a blowtorch.

Jun 14, 2009. 9:30 AM REPLY

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

Goodhart says:
Gee, looks like I'll never get to use my 100 A arc welder ever again.... ;-)

Sep 12, 2009. 8:04 AM REPLY

mdgnys says:
Oh I have one of those!!!!!!!!!!!!!!!!!!!!

Sep 11, 2009. 8:02 AM REPLY

1337pato says:
Burn

Sep 9, 2009. 7:38 PM REPLY

DavidHasselhoff says:
ROFL

Sep 9, 2009. 11:36 AM REPLY

ATG says:
LOL

Jun 14, 2009. 2:03 PM REPLY

Chromatica says:
lmfao

Sep 10, 2009. 1:19 PM REPLY

Kasm279 says:
lol!

Sep 11, 2009. 5:58 AM REPLY

random green dude says:


LMAO

Sep 12, 2009. 2:55 AM REPLY

-henry- says:
It's nearly impossible to burn the PCB when you solder, unless your soldering iron is WAY to hot.

Feb 3, 2009. 5:00 PM REPLY

Sagar Gondaliya says:


i put mine at 800+ degrees. is that bad?

Feb 17, 2009. 10:47 AM REPLY

Malfurious says:

Jan 7, 2010. 1:32 PM REPLY Using a material that has a melting point above 800F is brazing. Most likely, your soldering iron isn't designed to sustain those high temperatures. Are you using a material that requires your gun to be that hot?!?

-henry- says:
You realize that you responded to a post almost 1 year old FYI

Jan 7, 2010. 4:24 PM REPLY

WilderLust says:

Sep 11, 2009. 9:08 AM REPLY Wow! you don't need it so hot. most of the work i do is under 300 deg. sometimes when i have larger cables or large metal parts to solder i go up farther but 800 is really high for electronics. your element will last longer at lower temps too and you will not fry so many things. the solder i use melts around 250 deg. i would recommend you cool things down for electronics! cheers :-)

Sagar Gondaliya says:

Sep 12, 2009. 10:45 AM REPLY Ty. i only keep it hso hot so i can get done faster :| Thanks for the warning. im gonna make it so it cant get past 450

-henry- says:
that's fine, anywhere from 700-900 degrees (F) is fine for soldering,

Feb 17, 2009. 4:11 PM REPLY

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

Sagar Gondaliya says:

Feb 18, 2009. 3:03 PM REPLY thnx cuz sometimes my dad gets mad when i put it that high. just wanted to make sure that i wouldnt damage anything. thnx again

thecheatscalc says:
by the way, what type of solder are you using? electronics solder is usually 350-400 degrees Fahrenheit...

Sep 4, 2009. 4:38 PM REPLY

view all 144 comments

http://www.instructables.com/id/Hacking-a-USB-Keyboard/

Вам также может понравиться