Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Press Escape key to call method

Tags:

methods

c#

key

Is there a way to start a method in C# if a key is pressed? For example, Esc?

like image 755
raimis Avatar asked Nov 25 '09 17:11

raimis


People also ask

How do you press Escape key?

Short for Escape, Esc is a key found on the top-left corner of a computer keyboard. It allows the user to abort, cancel, or close an operation. For example, if a web page was loading slow on an Internet browser, pressing the Escape key stops the download.

What does pressing the escape button do?

True to its name, the Esc key acts like a “Cancel” button on most computers. On Windows, for example, the key can be used to close a dialog box without having to click “Cancel” with a mouse button. You can also use the Esc key to cancel loading a website in a browser.

What is Escape key called?

On computer keyboards, the Esc key Esc (named Escape key in the international standard series ISO/IEC 9995) is a key used to generate the escape character (which can be represented as ASCII code 27 in decimal, Unicode U+001B, or Ctrl + [ ).

What is the Escape key in Java?

In Java, a character preceded by a backslash (\) is an escape sequence.


1 Answers

use the OnKeyPress Event of your textbox and in the event

if(e.KeyCode==Keys.Escape)
{
    yourTextBox.Text = string.Empty;
}
like image 183
Gregoire Avatar answered Sep 19 '22 05:09

Gregoire