static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 frm = new Form1();
frm.KeyPress += new KeyPressEventHandler(new KeyPressCode().keypressEvent);
Application.Run(frm);
}
}
public class KeyPressCode
{
public void keypressEvent(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Escape)
{
MessageBox.Show("Key ESCAPE pressed.");
}
}
}