Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //by MSDN - Microsoft
- #include <iostream>
- #using <mscorlib.dll>
- using namespace System;
- int 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) != ConsoleModifiers()) Console::Write("ALT+");
- if((cki.Modifiers & ConsoleModifiers::Shift) != ConsoleModifiers()) Console::Write("SHIFT+");
- if((cki.Modifiers & ConsoleModifiers::Control) != ConsoleModifiers()) Console::Write("CTL+");
- Console::WriteLine(cki.Key.ToString());
- } while (cki.Key != ConsoleKey::Escape);
- return 0;
- }
- //se der erro /clr so ir em Configuration Properties -> General -> Common Language Runtime Support e marcar /clr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement