Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Example
- {
- public static void Main()
- {
- ConsoleKeyInfo cki;
- // Prevent example from ending if CTL+C is pressed.
- Console.TreatControlCAsInput = true;
- Console.WriteLine("Press any combination of CTL, ALT, and SHIFT, and a console key.");
- Console.WriteLine("Press the Escape (Esc) key to quit: \n");
- do
- {
- cki = Console.ReadKey();
- Console.Write(" --- You pressed ");
- if((cki.Modifiers & ConsoleModifiers.Alt) != 0) Console.Write("ALT+");
- if((cki.Modifiers & ConsoleModifiers.Shift) != 0) Console.Write("SHIFT+");
- if((cki.Modifiers & ConsoleModifiers.Control) != 0) Console.Write("CTL+");
- Console.WriteLine(cki.Key.ToString());
- } while (cki.Key != ConsoleKey.Escape);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement