Module Module1
Sub Main()
Dim v_exitpointer As Boolean = False
While v_exitpointer = False
' --- Main Programm
' --- Check to see if there is a console key pressed,
' and break the loop if it was escape
If Console.KeyAvailable = True Then
Dim mykey As ConsoleKeyInfo = Console.ReadKey
If mykey.KeyChar = Chr(27) Then v_exitpointer = True
End If
End While
End Sub
End Module
Detecting a keypress in a console application
The following code example runs a console application in a loop, until the escape key is pressed.