I have a regular button called Btn_Down that activates when clicked, but I also want it to activate when the ‘S’ key is pressed. Can anyone help me out with this?
>Solution :
Subscribe to KeyDown event of form control which contains your button and add following code
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyData)
{
case Keys.S:
button1_Click(this, EventArgs.Empty);
//Or
//button1.PerformClick();
break;
}
}
Set form’s KeyPreview property to true. These settings should give the effect you want.