KeyEventArgs.KeyCode : KeyEventArgs « System.Windows.Forms « C# / C Sharp by API






KeyEventArgs.KeyCode

 

using System;
using System.Drawing;
using System.Windows.Forms;
   
class ExitOnX: Form
{
     public static void Main()
     {
          Application.Run(new ExitOnX());
     }
     public ExitOnX()
     {
          Text = "Exit on X";
     }
     protected override void OnKeyDown(KeyEventArgs kea)
     {
          if (kea.KeyCode == Keys.X)
               Close();
     }
}

   
  








Related examples in the same category

1.KeyEventArgs.Alt
2.KeyEventArgs.KeyData
3.KeyEventArgs.KeyValue
4.KeyEventArgs.Modifiers