Fix infinite loop when iterating through a KeyboardState.