IO 使用readKey即时显示数据到控制台
View Code
static void Main(string[] args)
{
ConsoleKeyInfo c = new ConsoleKeyInfo();
ConsoleKeyInfo cki;
do
{
cki = Console.ReadKey();
if ((cki.Modifiers & ConsoleModifiers.Control) != 0)
Console.WriteLine("ctrl");
if ((cki.Modifiers & ConsoleModifiers.Alt) != 0)
Console.WriteLine("alt");
if ((cki.Modifiers & ConsoleModifiers.Shift) != 0)
Console.WriteLine("shift");
} while (cki.Key != ConsoleKey.Escape);
}
{
ConsoleKeyInfo c = new ConsoleKeyInfo();
ConsoleKeyInfo cki;
do
{
cki = Console.ReadKey();
if ((cki.Modifiers & ConsoleModifiers.Control) != 0)
Console.WriteLine("ctrl");
if ((cki.Modifiers & ConsoleModifiers.Alt) != 0)
Console.WriteLine("alt");
if ((cki.Modifiers & ConsoleModifiers.Shift) != 0)
Console.WriteLine("shift");
} while (cki.Key != ConsoleKey.Escape);
}
使用readkey键来即时显示数据,直到按esec键为止