This is an instructable about how to map the innards of a keyboard. More specifically, we're going to try to find which contacts connect with each other to create each unique keypress. For those less versed in how keyboard's internals work, the next step will be a quick explanation, with some links for further reading. If you already know how membrane keyboards work, feel free to skip it.
I'm not sure why you'd want to do this, but my reason was just to have the option of using the mapping data in a future project - and I wanted to break open an old keyboard I had lying around. You may be able to use this mapping and the circuit board to make your own game controller or similar interface, though it would likely be much easier to do it some other way.
Step 1: Keyboard Internals Details
Most keyboards these days are membrane keyboards. They're cheap and easy to mass produce, and chances are you're using one right now.
Membrane keyboards work by using a matrix of open switches. Each time you press a key, it depresses a small rubber dome. When this dome is squished, it presses down on the membrane. Each spot with a key has this dome, and likewise the membrane has a small gap inside. As seen in the first image, there's a few layers to the membrane. When the key is pressed, the top layer and the bottom layer get pushed together, closing the switch. When the keyboard sees these two contacts have touched, it knows that key was pressed.
Here are some links for further reading - and if you have any questions, feel free to leave a comment.
Section 3 of this article: http://www.explainthatstuff.com/computerkeyboards....
This one is talking about keyboard ghosting, which is closely related to this. We can see later how the designers of my keyboard set the keyboard up to prevent ghosting. http://www.microsoft.com/appliedsciences/antighost...
Step 2: Disassemble Your Keyboard
First a word of warning. DO NOT do this with the keyboard you use for your computer. You will very likely not be able to put it back together. That said, not all keyboards cooperate with this project, although most models should allow some variant. If you're having issues, leave a comment with some detailed pictures of your keyboard and I'll see if I can help you out. Lastly, if you've only got an expensive keyboard, go get a cheap one to play with, and don't use it for this instructable unless it's already broken.
Back to the fun bit.
First, remove all the screws from the back of the keyboard, then carefully take the back off. Often, the little rubber caps will be loose inside the case (held in place by pressure), so make sure they don't escape. Next, free up the membrane. With most cheap keyboards, this is just a few thin pieces of plastic. Don't try to remove it, just make sure you can lift it up. If you can't easily do this your model of keyboard may not work, but feel free to keep reading.
Step 3: Mark the Pins
I separated my pins by which layer of the membrane they were attached to, along with which grouping they were part of. The top layer was Y and Z, and the bottom layer was A and B. I used this notation to keep track of which pins went to which keys.
Step 4: Mark the Membrane
After marking the pins, use the top of the keyboard to mark where each key pressed on the membrane. You should be able to use the top part of the keyboard with the key caps as a sort of pattern to see which contact matches which key. I wrote with a pen on the clear plastic - it's barely visible in the picture. If there's multiple contacts that look like they go to the same key, look for a small amount of wear around the contacts. The one that matches up with the key should have worn down a bit, while the others should be untouched (unless they go to other keys).
Step 5: Trace the Traces
Now is the hard/time consuming part. It took me around 2 hours to trace all the paths. Before you start, set up a table like the one in the second picture. It's a bit messy, but the general idea is there. Each column was a different top pin, and each row was a different bottom pin.
Keen eyes may have seen that I used a series of dots and dashes on each trace (the lines). Each trace had its own unique set of dashes and dots. Every few centimeters, I marked this series. This helped tremendously with keeping up with which traces are which when there's 8 in parallel. There are some more examples of my traces in the other pictures.
On the left side, I marked which keys were on the trace for which pin, along with my unique dash/dot set. As you can see in the image, B, G, V, F, R, T, 4, and 5 (not actually marked here, I missed it the first time around) were all attached to the first B pin, B1. The left arrow, up arrow, end button, and home button were attached to B2, and so on.
Once done with the bottom pins, I started tracing the top pins. When I found a key on that trace, I marked it in the corresponding cell.
Step 6: Clean Up Your Notes!
Once all the traces have been traced, and all keys have been keyed, transcribe them to a nice neat piece of graph paper. This will help you see more clearly which keys match with which combo of pins.
Step 7: All Done!
You're done! You've now successfully mapped your keyboard! All that's left is to find something to do with your newfound knowledge. Maybe make your own game controller. Use it as an interface for an arduino. If you're feeling really ambitious, make a gaming glove like the peregrine http://theperegrine.com/