

Task

Obtain a valid   Y   or   N   response from the keyboard.

The keyboard should be flushed, so that any outstanding key-presses are removed, preventing any existing   Y   or   N   key-press from being evaluated.

The response should be obtained as soon as   Y   or   N   are pressed, and there should be no need to press an   enter   key.




PrintN("Press Y or N to continue")
 
Repeat
  ; Get the key being pressed, or a empty string.
  Key$=UCase(Inkey())
  ;
  ; To Reduce the problems with an active loop
  ; a Delay(1) will release the CPU for the rest
  ; of this quanta if no key where pressed.
  Delay(1)
Until   Key$="Y" Or Key$="N"
PrintN("The response was "+Key$)