CD4021BE for Buttons instead of Switches

spycatcher2k:
You only need 8 pins for a 4x4 array of buttons.

There's 16 LEDs as well as 16 buttons. I gotta control them all individually so it's a bit elaborate.

Smajdalf:
It should work well for push buttons if sampled quickly enough.

Sampled quickly enough... the button is a momentary switch, so it'll just send the signal for a very short amount of time. You're saying I can see that quick connection? How do I make sure I'm "sampling quickly enough?"