using System; namespace ConsoleApplication { class Program { staticvoid Main(string[] args) { bool a =false; ConsoleKeyInfo keyInfo; while (!a) { if (System.Console.KeyAvailable)//如果有键按下 { keyInfo = System.Console.ReadKey(true);//读取 if (keyInfo.Key == ConsoleKey.Escape)//判断 { a =true; } } } } } }