PaulRB:
Pro Micro has 18 pins according to this page. So only 2 fewer than Leonardo.
You are absolutely right! On amazon it said 12 I/O - my mistake not double checking it on a another page.
Paul__B:
The diode is of course, a "general purpose" diode: 1N914/ 1N4148. You can get SMD versions if you are going to make a PCB and there are multi-diode packages, but those are not going to be particularly practical.
I might have found a solution for not having to solder everthing myself:This thing seems like it is doing exactly what I want, including inbuilt pullup/pulldown resistors. I would need two of them, but as they are not that expensive, I might save myself from soldering 40 diodes...
What might be limited is the amount of keys that cane be detected as "pressed down" at the same time. But you should ask yourself if you really need the ability to have more than 10 buttons physically pressed at the same time. I think keyboards usually do about 6 letter keys + 4 modifier keys at the same time. So you should be able to do 10 physical toggle buttons if you wire them up wisely. But honestly, I would just got with normal switches and do the toggling in software, this way you could make all your buttons act as toggle buttons if you wanted to. But yeah, you could also get a keyboard that supports "all key rollover" or whatever they call it these days.
PaulRB:
No, I can't see that those chips or libraries will save you from having to add the diodes.
You are right if I use them for a matrix input. But I thought just using 2-3 of them and then simply connecting each input with a button. Not very sophisticated, but maybe a bit less prone to errors in the wiring, I am really afraid of making a huge mess with 40 diodes and soldering without have a PCB.
I even found something simpler in terms of expanding I/O: mcp23017
You are right, 3 x mcp23s017 would also work and you would not need the diodes. But its 3 more chips than the zero chips you would need with a matrix. Each diode in your matrix is one more solder joint. For 48 buttons, that's 48 more solder joints. MCP23S17 is a 28-pin chip, so 3 of them is 84 more solder joints.
Sorry if did a mistake here, but I don't really understand why this is cross-posting: The post here was general help for the project, the other post was specifically about multiplexing (which was not answered here) but could not be understood well without some background, I think.