Set the Form 'KeyPreview property to 'true, and write an event-handler for the Keydown event on the Form:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.F1:
break;
}
}
If that doesn't work for some reason (like you have some DirectX using Control which has the current focus and is not forwarding key-messages to the WinForms), then try this:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
switch (keyData)
{
case Keys.F1:
break;
}
return base.ProcessCmdKey(ref msg, keyData);
}