Arduino code for multi button state change detection
Not a review, but an extended comment.

This is a very common problem. Polling the bunch of event sources is easy to implement, but it leads to the flaws you've discoverd. The only way out is to abandon polling, and switch to interrupts. In your case, consider to

    attachInterrupt(digitalPinToInterrupt(pin), ISR, RISING);


for each pin you are interested in, during setup. The ISR shall push a pin which triggered it into a queue. Then the loop would pick the pin numbers from the queue, and do whatever is relevant.

Be careful with synchronizing the queue between the ISR and the main line. Solving the synchronization is hard, but very enlightening.