Making a timer-using Raspi console app stoppable?

I use a xojo timer in a Raspi console app and want to get a keyboard input to stop the loop.
I found this thread and set up a similar method, but Result always stays at length 0. Any ideas what I might be making wrong?

result ="" do app.DoEvents result = result + stdin.ReadAll loop until result.Right(1) = "x"