decreasing keypad pins

Here's my suggested way using 2 shift registers & 5 IO pins.
Replace SPI IO names with shiftOut() & shiftIn() names if you prefer slower scanning.
I'd also control SSO & SSI with direct port manipulation.
2 code choices shown; for loop will scan slower than in-line coding.