Rewiring the Keys with Diodes
We will replace the resistor ladder with something better: A keyboard matrix. Here is a circuit diagram:
You can see from this schematic why it's called a matrix. However it is perhaps slightly easier to understand when drawn like this:
The keys are split into groups of 8. Input I0 is held high, and outputs O0-O7 are read, giving the value of the highest group of 8 keys. Next input I1 is held high, and the outputs read again, giving the state of the next 8 keys, and so on. With this method, 8 inputs and 8 outputs can sample up to 64 key switches. My keyboard has only 37 keys so only 5 inputs are required. The diodes in the circuit prevent current flowing back through outputs and into another bank, causing a "ghosting" effect.
First remove the resistors from the plastic holder and install the diodes. I used 1N5818 diodes because that is what I had available, but you should be able to get away with just about any diode that is rated for 3.3v. The most optimal diode to use is the 1N4148, which is designed specifically for applications such as this.
Next, wire together the output of every eighth diode giving the eight outputs from the key matrix. Cut the metal contact strip into sections of length 8 keys. Each section forms one input bank. Finally I soldered each bank of inputs and outputs onto a piece of strip board, with some solid core wires, suitable for plugging into prototyping board. You may prefer to use proper connectors or make other arrangements depending on what microcontroller board you are using and what connectors it has (if any.) Pictures:











