Woo hoo !
Polling is very inefficient in large Systems (it's very easy if you have just a few items like 2 Sensors and a Servo),
so it's done by Interrupts.
check if key is pressed - do something when it happened
Main Program does something;
The Interrupt-Logic waits till a key is pressed, then --> Interrupts the Main Program, tell a Key is pressed (Send a Signal) and the Main Program does something and continue at that point when the interrupt came (maybe with changed Values).
The Interrupt-Logic waits till the key is released, then --> Interrupts the Main Program again, send the Key Released-Signal and the Main Program does something and continue at that point when the interrupt came.
The Main Program does not waste time with waiting (there is no x), the Interrupt-Controller waits independent and sends only Signals to the Main Program.
Then it depends on the programmer, how he want to deal with those Signals.
Working with Interrupts is a complete different way of programing, due the separation from the code sequence into Hardeware (it can happen at any time), the Compiler can't test all possibilities.
If you know what you're doing, it's fast and cool.