Matrix keyboard & shifting-zero algo: possible short?

I need to read a very basic 3x4 numeric keypad connected directly to my pi. I've read some and decided to go with the so-called shifting-zero algorithm: have 4 pins connected to the keyboard's rows and configured as outputs and another 3 pins connected to the columns configured as inputs, with the internal pull-up resistors enabled. The reading loop would then look something like:

foreach (outputPins as row => outPin) {
set outPin low
foreach (inputPins as column => inPin) {
if (inPin is low) // key at [row][column] is pressed
}
set outPin high
}

(sorry for the pseudo-code ;-) )

There's more logic inside the inner loop related to debouncing the keys etc, but that doesn't directly relate to the question. Because it seems to me that if I press two keys in the same column at the same time, then setting one of the key's corresponding row pin low would effectively short the other key's corresponding row pin (which, in the meantime, is high) to ground. That, I believe, could damage my pi. Or could it? I can't really tell :-) I'm not terribly experienced at this stuff.

I was thinking about connecting a small resistor, say 470R, in series between each output pin and it's corresponding keyboard row. But that wouldn't solve the problem, because if I then press two keys at the same time, the two resistors (along with the internal pull-up) would then form a voltage divider which would cause the input to see something around 1.65V (3.3V / 2) which I don't believe it would really like. Even if it did, it wouldn't read anything useful, which would kind of defeat the whole purpose.

I figure maybe it could be done with diodes then: instead of a resistor, I'd connect a 4148 or the like between each output pin and it's row, it's cathode to the pi, anode to the keyboard. That way the diode disables any current from flowing from the output pins, but still would permit those pins to sink current. But a diode needs some voltage across it to open (typically 0.7V I believe). I think that that's ok as the input pins would have their internal pull-ups enabled thus providing the required voltage, but then the inputs would still see 0.7V instead of 0.. or would they? And if they do, would that still read as a "low"?

Or is there another solution which I'm completely unaware of? O.o

Thanks for any tips!

• there are separate USB numeric pads available, why not use one of these? Jan 25, 2014 at 6:36
• Can't. I need the USB ports for other stuff, plus I need the keypad to be wall mounted & vandalism-tolerant, so a regular PC numpad won't cut it for me. Plus it would mean effectively exposing an USB port to the outside world which makes it a security risk. Jan 25, 2014 at 10:24
• You only mention 2 simultaneous keys, but to properly prevent all ghosting you really need a diode inline with every key. Many mechanical keys include a holder for one. Jan 25, 2014 at 22:35