I have a naive keyboard matrix (no diodes, so only 2 simultaneous key presses can detected, at most).

I would like to read this matrix by connecting the columns to GPIO pins configured as outputs and the rows to GPIO pins configured as inputs.

By driving the column pins, one at a time, it should be possible to test which keys are pressed by reading the GPIO input pins.

(I will run a polling daemon, written in C, to read the matrix, and squirt data into the kernel using the uinput kernel driver.)

Will I fry the RPi by connecting GPIO-outs to GPIO-ins?

(If GPIO inputs act as near infinite resistances, then there will be no problem - but I don't know this.)

2 Answers 2


No, you won't fry the GPIO pins. The RasPi doesn't really care where the signal's coming from or going to as long as it conforms to the 3.3v logic level on the inputs, and doesn't draw more than 8ma from the outputs. See this for a more complete discussion of pinouts and restrictions. Note that two of the GPIO pins are intended for I2C and have 1.8K pullup resistors attached.

Your key scanning scheme should work- it's often implemented on numeric keypads- as long as you have enough I/O ports for the job. You might want to investigate a keyboard encoder chip to make things simpler. Many of them include debouncing and 2 key rollover protection.


There is the risk of accidentally getting both pins configured as output at some point. Maybe you could add some series protection resistors to the input lines (and perhaps output)? That would give some extra safety and should be dimensionable so there will be no voltage lost from "low" impedance outputs to high impedance inputs. There should be no problem with edge speed on keypads :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.