Tuesday, 3 September 2013
Killing Application With Escape Key in .NET C#
Posted on 09:40 by Unknown
So, you are a C# weenie and you want to kill your Forms Application by hitting the escape key. It's as easy as pie.
In the forms load method, put in the following two lines:
this.KeyPreview = true;
this.KeyDown += new KeyEventHandler(Form1_KeyDown);
Then create the KeyDown method:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
Application.Exit();
}
}
Hope this helps.
Posted in .Net, c#, end application, Escape Key, keylistener, kill application, source code
|
No comments
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment