When I press F10 in my program, the focus is lost from my main program window, and moves to the menu bar. It turns out this strange behavior is common across many Windows apps.
I think it's ugly because the Alt key does the same thing, and we lose a precious function key. Why is Windows doing this, and how can I solve the case for my C# app?
Use the KeyDown Event for your form, and handle the Keystroke:
private void form_KeyDown(object sender, KeyEventArgs e)
{ if(e.KeyData == Keys.F10)
{
// Do what you want with the F10 key
e.SuppressKeyPress = true;
}
}
Also make sure that your forms KeyPreview is set to true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With