Console.ReadKey (Boolean) gets next character or function key pressed
Class Example
Public Shared Sub Main()
Dim cki As ConsoleKeyInfo
Console.TreatControlCAsInput = True
Console.WriteLine("Press the Escape (Esc) key to quit: " + vbCrLf)
Do
cki = Console.ReadKey(True)
Console.Write("You pressed ")
If (cki.Modifiers And ConsoleModifiers.Alt) <> 0 Then Console.Write("ALT+")
If (cki.Modifiers And ConsoleModifiers.Shift) <> 0 Then Console.Write("SHIFT+")
If (cki.Modifiers And ConsoleModifiers.Control) <> 0 Then Console.Write("CTL+")
Console.WriteLine("{0} (character '{1}')", cki.Key, cki.KeyChar)
Loop While cki.Key <> ConsoleKey.Escape
End Sub
End Class
Related examples in the same category