Would like to detect esc key to escape the forever loop in pseudo code:
forever [ url: ask "Url: " if (url = esc) [ break ] ]
Is this possible ?
As a pure console application, I'm pretty sure the answer is no.
esc is used to cancel the execution of the script.
You can disable that use of esc....
system/console/break: false
....And the esc key now does nothing.
If you switch to REBOL/VIEW and are happy to use a pop up request-text box rather than a console ask line, then you may be able to trap esc using insert-event-func.
There is no simple answer, you must use own console-port to handle it correctly, here is the part of it taken from one of my old projects:
You will probably like to change the ctx-console/on-escape and ctx-console/on-enter functions.