So I've got a bit of a tricky one. Well, I'm finding it tricky anyway, the solution might be really simple. I started a project a while ago to gut a dead* 2002 Titanium Powerbook (15 inch DVI) and install a Raspberry Pi in place of the logic board. I want to use the built-in keyboard directly and figured a Leonardo would be the best - well, easiest - way to create a USB interface for that matrix.
So far I have:
Verified that a Leonardo can be used as a keyboard to control the Pi, I did this by creating a simple sketch to type the letter 'a' when a pin went low, which worked, so that's good enough for me!
Created a pinout for the keyboard connector by probing all of the connections, everything is present and correct.
Read the resistance for each key on the keyboard. Yeah, this one threw me a little but it makes sense, as I'll explain soon.
My problem now is: How do I read the keyboard quickly enough for it to react at the speed you'd expect of a normal keyboard? Or am I supposed to use some sort of buffer?
Going back to the key's resistance; I discovered almost by accident that each key has a resistance that is unique. Some of the resistance values are repeated on different columns, but each column has a unique resistance for each key. So this makes me wonder if the ten columns were being read by an ADC to get a binary value for each key to prevent ghosting... But do I need to worry about ghosting, really? I can't think of a time I've ever had to press two non-modifier keys at the same time and I generally don't type quickly enough to ever press two keys at the same time accidentally! It seems like a lot more work to use ADCs to read the voltage given by each key, and I need to keep the size of whatever circuit I come up with really small anyway. It's not as if I'm going to be gaming with my Pi!
But anyway, getting back to the point; am I supposed to keep the latency of reading the rows right down so that the Leonardo can read it in real time and hope that I don't type so quickly that it can't keep up, or do I need some sort of a buffer? If I do have to have a buffer, where do I even start with that? I've never used anything remotely buffer-like (except for using an Arduino itself to shift bytes in from a CMOS PISO register and back out to a TTL SIPO one).
Let's say I make a system that uses the Leonardo to shift out a constantly left-shifting byte (i.e. 0000 0001, 0000 0010, 0000 0100, etc.) to cycle the rows, and at the same time it 'listens' to the ten columns directly. When it digitally reads a '1' on, say, pins 2-11, it will work out which byte it was shifting out at the time (say for the sake of argument it's 0000 0001, as in row A) and compare that to the pin that went high (again for the sake of argument it's pin 2, as in column 1) to get the co-ordinate of the pressed key (which would be "F1"). Could that be done quickly enough, or would I need to have a buffer between the columns and the Leonardo to 'save' the state of the row and column until the Leo can read it, at which point it resets again?
So yeah, I don't know. In terms of the whole project this is really the only part that has to work, I really don't mind using a mouse with it instead of the trackpad and there's only a really, really slim chance the display will work anyway; if it doesn't I might fabricate a custom lid for a different 15 inch LCD, but I'm more likely to install a plethora of display connectors on the back instead and just use it as a portable Pi without having to carry all the superfluous parts around.
TL, DR: Does keyboard ghosting really matter, and can a Leonardo work quickly enough by itself to read the inputs without missing any keystrokes?
Ladies and gentlemen, I thank you all greatly in advance.
*Dead = missing hard drive, backlight inverter... That was it, so not really all that dead.