I am trying to write a simple program that prints a message every time the
user presses a key. The trick is that I would like this to happen
*regardless* of what the program is doing otherwise. Eventually, I would
like to use this method to interrupt a long running process, and allow me
to check it's progress and modify parameters before restarting it, however
I am struggling to get even this basic example to work. The following code
snippet works in the REPL:
function myTask()
wait(STDIN.readnotify)
println("Key Pressed!")
end
@async myTask()
However it doesn't work when run as a script (because it exits before
myTask completes). Adding an @sync begin ... end block around the @async
call doesn't fix the problem in the script, and actually breaks the REPL
version as well. How should I check for user input without actually
stopping to wait if there is none?
Thanks in advance for your help,
Luke