ConsoleSpecialKey Enumeration
Class Sample Public Shared Sub Main() Dim cki As ConsoleKeyInfo Console.Clear() Console.TreatControlCAsInput = False AddHandler Console.CancelKeyPress, AddressOf myHandler While True Console.Write("Press any key, or 'X' to quit, or ") Console.WriteLine("CTRL+C to interrupt the read operation:") cki = Console.ReadKey(True) Console.WriteLine(" Key pressed: {0}" & vbCrLf, cki.Key) If cki.Key = ConsoleKey.X Then Exit While End While End Sub Protected Shared Sub myHandler(ByVal sender As Object,ByVal args As ConsoleCancelEventArgs) Console.WriteLine(" Key pressed: {0}", args.SpecialKey) Console.WriteLine(" Cancel property: {0}", args.Cancel) args.Cancel = True Console.WriteLine(" Cancel property: {0}", args.Cancel) End Sub End Class