How to have 3 more pin on Micro?

I have an old gamepad with the support to put on a smartphone. The right trigger doesn't work very well, and even after resold the logicboard of the button to the mainboard, it still has issues (the triggers have the function to simulate the pressure. The left one has no problem. The right one doesn't simulate the pressure, giving back the maximum input, but the signal is not constant) I was planning to replace the mainboard with an Arduino Micro using this library. So, the problem is that I need 23 I/O to have all buttons working, when Micro has only 20 (the analogs need a total of 4 Analog pin and 2 Digital pin. The others buttons needs 17 Digital input, 16 if I don't use the Home button). Navigating the web I found this thread. Since they have the same ATmega32u4 but I don't know if they have the same mainboard, it is possible to use this sistem to have 3 more pin? Or there are some other solutions to have more pin? Nothing too much expensive or complicated

You can use MISO/MOSI/SCK if not already in use.

Alternative is e.g. port expanders (I2C or SPI) or shift registers (74HC595 for output, 74HC165 for input).

A 5*5 matrix of up to 25 switches can be controlled by 10 digital pins.

sterretje:
You can use MISO/MOSI/SCK if not already in use.

Alternative is e.g. port expanders (I2C or SPI) or shift registers (74HC595 for output, 74HC165 for input).

Ok so, how do I setup this three pin? Like the others with pinMode(pin, mode)? Do they have INPUT_PULLUP?

DrDiettrich:
A 5*5 matrix of up to 25 switches can be controlled by 10 digital pins.

Can you please give me some example?

Search the forum for keyboard matrix.