(see the bottom of the article)
A keyboard has its own processor and circuitry that gets the information from momentry switches (The keys) the large part of this circuit is called a matrix.This is what we will be reverse engineering as it were.
I have a couple of projects which require a custom keyboard one of them being a MACH3 control box for my CNC project or maybe a MAME controller.
There are a few ways to emulate a keyboard for such a project one of them being a Pokeys.
Mach3 Control box
Another way would be using a PIC or an AVR micro controller but its a bit of a learning curve.So here we have a quick and dirty guide to making your own at a minuscule cost.
Keyboards these days can be bought for as little as £5 or just use a donor, PS2 or USB they use the same principal.
The Victim..............This particular donor keyboard has multimedia control which would come in handy for quite a few things.
Heres the bit that we are after !
Now mark the pins on the board and the top/bottom connectors if not already marked.Different keyboards will use different connectors but the bottom and top layers will always be separate in some way.
Here we have an 18 pin top layer connector on the left and the 8 pin bottom layer connector on the right.
Each one of the lines on the ribbon cable represents a non returning circuit.The Micro controller on the PCB detect which key has been press by a combination of these pins just like coordinates as an example the number 9 equals a short between top layer pin 12 and bottom layer pin 8 or 12,8 as you will be writing all these combinations down as you go.
Here you can see 3 layers,the top an insulating layer plus the bottom layer.
To start testing bottom layer you will need a multimeter on the continuity mode depending on the sensitivity of the multimeter and due to the length of tracks there can be quite a bit of resistance so even though you meter is set on beep in actual fact you may just have to look at the screen for a change in resistance.
As you get continuity between the bottom layer and the PCB connector using a marker write the pin number on the bottom layer for each circuit as shown below.
Before you start testing top layer for continuity I found it useful to write the actual key names onto the layer film.You may only need a few keys for you project such as the CONTROL,ALT and DEL comical dig at windows keyboard this will make the process alot quicker as you can cherry pick only the keys you will need.
I initially thought testing the top layer for continuity would be a pain as it has more than twice the amount of connector pins, but actually it was far easier, due to the fact many keys are grouped together closely and was easily visible as they shared the same circuit .
Mark the corresponding top layer pins and keys.
Below we can see an example ,the blue circle shows this track belongs to pin 15 on the top layer connector,the red shows the key name "4" and the yellow shows all the keys on the photo that share that circuit.
Here we can see pin 13 with the key name "i" and the pin 1 below on the bottom layer this would make 13,1 on the connectors.
So shorting these two pins on both connectors give us the letter "i" and so on .
All this marking makes it a lot easier to see corresponding pins through both layers.
Here's another example showing the key name "F5", top pin 3 and bottom pin 8 that gives us ?
Now you can write down the pins as you go much more quickly
When you are sure that you have the correct pin number configurations you can remove the PCB.
The black blob is actually the micro controller for the keyboard buried in epoxy ,on the whole its a pretty poorly soldered PCB shame on you Labtec!
Ready for a the transplant to a new home!
Here I removed the PCB connectors and used an old floppy drive cable to interface to the PCB.The older floppy/CD IDE cables (ATA33 spec) are the best for this as newer DVD drive IDE cables use two thinner wires for each one connection.
When dealing with a lot of small gauge wiring hot glue is your best friend ,it will stop any wire breakage due to movement.
Only use the hot glue when you are sure everything is wired correctly!
Using the wiring connection chart which we made earlier open notepad in windows then and using a bit of wire to prod into the relevant holes on the IDE plug watch the screen to see if the correct character appears.
Making a break out board (BOB) to interface with the outside world.
Vero board or strip board is the obvious choice here as we need to a lot of possible connections, it also allows us about every selection that was available on the old keyboard when using an IDE socket salvaged from an dead motherboard.
Unlike keyboard emulators such as the Pokeys there is no common ground as such ,but there are commons on both side of the layers .Multiple keys will share the same pin number on either layers and these can be chained together to save on addition wiring.
The Cursor Keys (Direction arrows)
Left number = Top Layer
Right number = Bottom layer
UP Arrow = 11,4
Down Arrow = 8,6
Left Arrow = 11,6
Right Arrow = 9,6
Any key sharing the same number on the same layer can be connected together these can be called common connections its just you have groups of commons instead of just one universal.So using the example above the bottom layer of the Down,Left and Right Arrows can share the same wire (pin 6) and visa versa 2 a share the same number (Pin 11) 8,9,4 would need a separate wire.
The Paper silkscreen will help with connecting momentary switches to the breakout board as it shows all the pin numbers.
Now its ready for any project requiring a custom keyboard.
Although the article was never aimed squarely at MAME controllers and after the article was published on Hackaday there was a lot of criticism regarding the suitability of using this method with Games that use multiply key presses at once .Some keyboard fair better than others, the ZBoard which is aimed squarely at gamers can handle 7 simultaneous key strokes at once.
I embedded a test keyboard for those that would like to test their keyboards suitability before hacking it to find different combinations of keys that would allow the most number of keystrokes at one time and show any signs of ghosting of keys .Some combinations will work better than others.
For a lot of the arcade classics you shouldn't see any problems but for complex fighting games etc. a specific MAME encoder would be more suitable.
Bear in mind when using the diagonal corners of an 8 way joystick you are actually holding 2 keys at once.
Click on the below keyboard then start typing to test combinations
I did a quick one minute test and was easily able to find a combination of 7 Keys (CTRL,Z,X,C,U,B,SHIFT) I could hold down at once with an Apple USB keyboard (on a PC) .I also did another test on a PS2 keyboard I had and was able to press a combination of 8 keys at once.
After these tests it made me think, if you needed more key presses at once just use two hacked keyboards as Windows lets you use multiply keyboards.I then tried both keyboards together and indeed found using the on-screen test keyboard that all the keys for both keyboard combinations worked at once.
After doing this hack I am pretty confident I could have a second one running in a few hours or even less if they were the same type/model.
I must be cheap as I have better things and projects to spend the $50+ TAX,Shipping on for a MAME encoder such as the I-Pac when I have the parts around ,plus you learn a few things on the way :) .One thing I have learnt from prototypes is to build the first one really cheap and then if it works great but if it doesn't work out spend the money on the next project. Or in different sentence you might say I work ASS BACKWARDS sometimes.
Please note when doing these tests you may have to turn off windows sticky keys if it should pop up with a warning.
I ran out of fingers so ask a friend to lend some a hand :)