Koren, want to post a diagram of all that? I've been planning to experiment with an I/O expander and shift registers for making keyboards, so it would be nice to see.
Will do... I'd rather test the circuitry before posting it, though, because there's sometimes strange timing issues you miss at first. And with shift registers and parallel to serial, it can be a bit tricky if you want to avoid too many wires.
That being said, there's an easier solution using mux/demux and a counter.
Quick'n dirty schematics (should be verified, and I wouldn't swear that those are the correct parts, just to illustrate the idea):
Counter on left, 4-to-16 in the middle, 8-to-1 on right (and an inverter on the upper right). This should drive a 128 keys keyboard (16x8 matrix) with only 2 outputs and 1 input from the microcontroller.
Initial state: 0 on Clock and 1 on Reset
Init: put 0 on Reset, then back 1 -> Data shows the status of the (0,0) key
Advance : put 1 on Clock, then 0 -> The next key state can be read on Data
Thus, you just have to alternate 1 and 0 on the clock line to scan the state of all the 128 keys by reading the data line. When you reach the last key, it go back to the first one. It can be quicker to use the reset/init if you don't use the 16 columns, though.
You could even get rid of the reset line, but you'll probably have to use a trick to know which key you're reading. An easy solution would be shorting the whole 1st column and not connecting the whole 8th line. You loose 23 keys (thus 105 keys keyboard) but the sequence of 8 consecutive high states means you've just scanned the first column, this giving you a reference.
The inverter (74LS04) could probably be avoided too by using a RC cell to delay the low-to-high transition on the CPR input. Values will depend on the IC and on the polling rate, though.
It's dead easy to add a second 74LS151 to get a 16x16 matrix or a second 74LS154 to get a 32x8 matrix, using the Q7 output of the 74LS590 and the "enable" inputs of the mux/demux.
But with this chip it would not work as an USB keyboard, right? Only via wifi with an adapter or driver?
That's a good question. Usually, the 328P in common Arduinos boards can easily act as an USB keyboard brain because they have a 8U2 (or 16U2) on board. The details on Piccolino are a bit scarse, but indeed, the 8U2 is probably missing, so you'd have to include it (assuming that you can connect it to the 328P). I'd say it's probably doable.
Or the alternative is to connect the Piccolino to a standard Arduino via SPI bus. The Piccolino can run the matrix scans, drive the screen, store data and communicate via WiFi while the other one communicate with the PC as a USB device.
There's probably no totally plug'n play solution with this board, but I'd say that the wireless and OLED already being available make up for the additional work to add the USB connection.
Also, keep in mind that we don't know for sure that you can connect the C.H.I.P. as a USB device either... and if you can't, it may be more difficult to add one.
Another possible shift register configuration would be using a 74HC164 driven by two wires to light the columns, and then a single wire as a line in a Nx1 "matrix".
Won't you need a lot of serial registers for a 50+ keys keyboard, though? Or did I understood you incorrectly?