Choosing a connector for a 12-wire keyboard scan matrix
Here is a rough diagram of a circuit that uses a mux and a demux to scan a key matrix.
It uses 6 data lines

Couple of  suitable ICs are 74ls138 and 74HC151.

The controller in the diagram could be replaced by a 5 bit counter.

The actual controller would then require only 3 data lines, reset, clock and data







simulate this circuit &ndash; Schematic created using CircuitLab







simulate this circuit