Click here to Skip to main content
15,906,625 members
Please Sign up or sign in to vote.
1.80/5 (3 votes)
See more:
Dear All.
i want to raise Esc key(keybord) Event, without pressing the Esc button.

Regards
Rajeesh MP
Posted
Updated 15-Jun-10 4:10am
v2

Hi,
You can use the enum "Keys" and use the value "Escape" to do raise an escape key action.
This will work in both C# & VB.NET windows forms.
Happy coding...! :-D
 
Share this answer
 
in your form properties choose cancelbutton to call any button to close the form

For eg:

form1

Button name : Quit

in quit button event write me.close

now call the quit button in your form properties cancelbutton.
 
Share this answer
 
Use SendKeys to send keystrokes and keystroke combinations to the active application. This class cannot be instantiated. To send a keystroke to a class and immediately continue with the flow of your program, use Send. To wait for any processes started by the keystroke, use SendWait.

C#
System.Windows.Forms.SendKeys.Send("A");
System.Windows.Forms.SendKeys.Send("{ENTER}");
 
Share this answer
 
Comments
[no name] 23-Sep-13 12:13pm    
Do you really think that the OP is still waiting for an answer after 4 and a half years?
Pradeep Shukla 23-Sep-13 12:18pm    
I know, I was also skeptical prior to adding my solution..but if someone else stumbles for the same question he should have a definitive answer.If I am spending my time on CP I would like it to be used to help others to the best of my knowledge.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900