Windows Forms – Enable Shortcut Key all over the Form

Windows Application and shortcut key are synonyms. People prefer to use shortcut keys for faster activity. Assume you are in a text box and you want to hit F5 to reload the form. You do not want to move your mouse cursor. So what you will be doing is that you will be adding “Key Down” event to the text box. But if you are in a different text box or in a button that will not work. So you will add “Key Down” event to your form.

But you need to enable a property to work it properly and that’s the trick.

private void Form1_KeyDown(object sender, KeyEventArgs e)


    if (e.KeyCode == Keys.F5)


        btnRefresh_Click(null, null);



But golden trick is, in the property window of the Form make the following changes

KeyPreview = True

Enjoy programming.