Just for fun a different spin ...
I originally came from a BASIC programming background (shoot me now), so when I took on LISP I found it annoying there wasn't an equivelent to the INKEY$ function (read a keyboard character from the keyboard buffer without requiring the user to press [Enter] and without echoing it to the screen).
What to do but write my own.
This is a simple variant that doesn't faithfully replicate said function (the original function left the character in the buffer and could deal with extended keyboard codes etc. IIRC) but it's good enough for a simple Yes/No application. If you execute the function it will wait until you press one of the standard keyboard keys: a-z, A-Z, 0-9, Spacebar, Enter, Tab keys etc. but not extended codes: <F1> key etc., returning the corresponding string, like "a", "A", "0", " ", "\n" or "\t" etc.
Anyway, without further blather --
(defun GetKey ( / result )
(while
(null
(eq 2
(car
(setq result (grread))
)
)
)
)
(chr (cadr result))
)
How to use? An simple example proggy --
(defun c:Foo ( / response )
(princ "Do you really want to do it? Y/N: ")
(while
(null
(member
(setq response (strcase (GetKey)))
'("Y" "N")
)
)
)
(princ
(strcat "User indicated <"
(if (eq "Y" response)
"Yes"
"No"
)
">."
)
)
(princ)
)
FWIW, cheers.