Describe your suggestion or idea
Use a port expander IC (i2c) to provide many more digital pins for I/O. With one MCP23017 you could have 8 digital inputs, all with input detection as per #1 and only use 2 pins for i2c, which could still have more devices on the same bus.
MCP23017s can have the i2c address set using the hardware pins, so you could even have 2 to give you 8 digital inputs with input detection, and then another 16 outputs on a separate chip on the same i2c bus.
Digital I/O using a port expander
Describe your suggestion or idea
Use a port expander IC (i2c) to provide many more digital pins for I/O. With one MCP23017 you could have 8 digital inputs, all with input detection as per #1 and only use 2 pins for i2c, which could still have more devices on the same bus. MCP23017s can have the i2c address set using the hardware pins, so you could even have 2 to give you 8 digital inputs with input detection, and then another 16 outputs on a separate chip on the same i2c bus.
https://thepihut.com/products/mcp23017-esp-io-expander