Windows applications and keyboard shortcuts are synonymous. People prefer to use keyboard shortcuts for faster activity. Suppose you are in a text box and you want to press F5 to reload the form. You do not want to move the mouse cursor. So what you will do is that you add the โKey Downโ event to the text box. But if you are in another text field or in a button, this will not work. This way you add the "Key Down" event to your form.
But you need to enable the property for proper operation, etc.
private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F5) { btnRefresh_Click(null, null); } }
But the golden trick in the form properties window makes the following changes:
KeyPreview = True
Enjoy the programming.
Mohamed dangra
source share