I recently bought the Makey Makey (based on Arduino Leonardo / ATMega32u4), hoping to construct a full USB steampunk-style keyboard from some metal parts. Before it arrived I re-read the details and realized it has only 18 possible inputs, so 85+ keys will not work. Does anybody have ideas how I could create such a beast, possibly with a Raspberry Pi? (which connects quite easily, from previous posts)
If you just want to make a keyboard, without using your Makey Makey, you can do that using the GPIO functionality of the Raspberry Pi. But like commented before, the Raspberry Pi does not have sufficient pins available to make a keyboard that is actually useful.
However, if you are willing to add 2 IC's you can make yourself a keyboard with so much keys that you will have a problem to come up with a function for every key!
My suggestion is to connect 2 I2C IC's to the I2C bus on the Raspberry Pi, and use those to create your own scan matrix.
If you use one PCF8574 you have 8 I/O pins available, if you get a PCF8575 you even have 16 I/O pins available. By combining then you can get a scan matrix of:
You have to use always one of them as output, and one as input. On the output you let a bit 'walk' from bit 0 to bit n (7 or 15), these are the columns of the matrix. On the other you constantly read the value of the input and these are the rows of the matrix. The combination of what output bit is active and what input bit is '1' is the key that is pressed.
Actually creating the matrix is the most work, and while you are at it, don't forget to add a diode after every switch you put in the matrix, this diode (a normal 1N4148 will do fine) needs to be placed with the anode to the switch and the cathode to the row line. The voltage drop of 0.6V over this diode should not be a problem, the remaining (3.3V-0.6V) 2.7V should still be a logical '1'.
The reason for this truckload of diodes is that it will prevent things like ghosting and masking of keys. Ghosting is the effect that if you press more then three keys at the same time, it is possible that it is interpreted as a totally different key because more rows will have a logical '1'. Masking is the effect that, if you have multiple keys pressed and release a key this will (in some situations) not be detected because the row for that key is still a logical '1'.
The picture shows an example of ghosting, buttons A, B, D are pressed and besides Row 1 (for button A) also Row 2 (for button C) is high, at the moment Column 1 is active, which is not correct.
After the whole hardware adventure, you need to write or adapt a kernel driver to actually use the keyboard under linux. A nice starting point might be this link: Driver for keys on TCA6416 I2C IO expander, this is a similar idea, but only uses a 16 keys keypad.
Hope this helps you a little.
If you want to make a full keyboard to actually type on, you'd probably be best off with the IC out of a USB keyboard. Either retain the PCB itself buried deep in your system where it can't be seen and run wires up to your switches, or fabricate something custom with the same matrix.
If you really need to change the electrical matrix then you might need to make your own design from scratch, but otherwise it's not really necessary.
Even with a custom board, you can still end up with something that enumerates and functions as a USB keyboard, removing the need for custom drivers.