"When you press a button it takes a while for it to register as unpressed, and until then you have a busy loop constantly hammering that if".
That's what I was thinking, but the keypress is logged over a timespan much larger than what a release time should be for just a press