For each button using a physical digital pin ATMEGA328P rv3 Arduino UNO. I want to use 8 relay outputs and 8 digital inputs with switches, it is the mentality I had. Requires many pins as digital inputs and I'm not.
At least I know how many buttons or buttons you can put on an analog input. Below explains something as done, at least 8 but not comment until buttons as can be. For example, if I want 20 buttons, calculate resistance. That's the mmotivo not do what I please.
There are 20 pins that can be used as digital input/output.
After that, it is easy to more using shift registers.
Relays often need more current, so a high current shift register such as TPIC6B595 is a good choice there to sink current from 5V thru the coil to Gnd. Be sure to add a diode across the coil to absorb any spikes generated when the coil changes state.
Inputs: use the internal pullup resistors, connect the pin to Gnd when the button is pressed and read a Low input.
When you are using an analogue input to read push buttons then number you can use is limited by the. Resoloution of the analogue to digital converter. If you do not want to detect more than one press at a time then in theory I would say you could have 256 buttons. This would leave a reading gap between buttons of a count of four.
This is about as much as you can get. Limiting this to 128 buttons would leave a bigger gap of eight between buttons.
At these limits ultimately it is a question of your skill with the circuit layout.