Program for Console.key()??

Sabarimahesh
Posted by Sabarimahesh under C# category on | Points: 40 | Views : 2028
class Program
{
static void Main(string[] args)
{
int a;

ConsoleKeyInfo keypress = Console.ReadKey();
if (keypress.Key == ConsoleKey.Escape)
{
Console.WriteLine("You are pressed Escape");
}

a = keypress.KeyChar;
if (a == 13)
{
Console.WriteLine("You are pressed Enter");
}


keypress = Console.ReadKey();
if (keypress.Key == ConsoleKey.X &&
keypress.Modifiers == ConsoleModifiers.Control)
{
Console.WriteLine("You are pressed CTRL+X");
}
Console.Read();

}

Comments or Responses

Login to post response