I need to real lines until ESC button is pressed. How can I check it?
lines
= do
line <- getLine
if (== "/ESC") --this condition is wrong
then ...
else do
ln <- lines
return ...
Could anybody fix my problem?
The correct way to escape is with a backslash, the character is
'\ESC', so the condition would beBut I’m not sure every terminal passes an
'\ESC'through to the application.If you want to stop immediately when the ESC key is pressed, something along the lines of
is what you need. You have to read character-wise, and you need to turn off the buffering of
stdin, so the characters are immediately available for reading, and not only after a newline has been entered.Note that on Windows turning off buffering didn’t work. I don’t know if this has been fixed recently.
Also, as @Daniel Wagner reported, it may well be that the Windows command prompt doesn’t pass the ESC to the application.