Console.KeyAvailable tells whether a key press is available in the input stream.
Imports System
Imports System.Threading
Imports Microsoft.VisualBasic
Class Sample
Public Shared Sub Main()
Dim cki As New ConsoleKeyInfo()
Do
Console.WriteLine("Press a key to display; press the 'x' key to quit.")
While Console.KeyAvailable = False
Thread.Sleep(250) ' Loop until input is entered.
End While
cki = Console.ReadKey(True)
Console.WriteLine(cki.Key)
Loop While cki.Key <> ConsoleKey.X
End Sub
End Class