实用代码:单个读取Console中输入的键

using System;
namespace ConsoleApplication
{
    
class Program
    
{
        
static void 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;
                    }

                     
                }
              
            }

        }

      }

}


原文地址:https://www.cnblogs.com/rockniu/p/1237703.html