If I insert that code into a test app:
public frmMain()
{
InitializeComponent();
this.KeyPreview = true;
this.KeyDown += new KeyEventHandler(frmMain_KeyDown);
}
private void frmMain_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.H)
{
myButton.PerformClick();
}
}
private void MyButton_Click(object sender, EventArgs e)
{
Console.WriteLine("Done");
}
Then every time I press "H" on the keyboard while the form has the focus, it prints "Done" in the output pane - which is what I expect.
So what are you doing that is different to me, given that I copy'n'pasted your code...