

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.




integer key
 
while get_key()!=-1 do end while -- flush

puts(1,"Your answer? (Y/N)")
 
while 1 do
    key = upper(get_key())
    if find(key,"YN") then exit end if
end while
 
printf(1,"\nYour response was %s\n",key)
