Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to use shortcut keys for button used on forms.
for example i want to close form on key press of Esc button on keyboard.
if any one having code for this pls forward it.
Thanks in advance.
Posted

HJi,

copy this code to your code:
C#
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
   if (keyData == Keys.Escape) this.Close();
   return base.ProcessCmdKey(ref msg, keyData);
}
 
Share this answer
 
on form key down event write this

if (e.keycode == keys.escape)
{
this.close
}
 
Share this answer
 

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