Function(F1,F2 ....F12) Key Event in Form - C#
This event executes whenever a user presses a function key in the Form.
First, we need to set
private void Home_Load(object sender, EventArgs e) { this.KeyPreview = true; }
We can detect most key presses by handling the KeyDown events. Use the following KeyDown
event to detect Function
key Pressed.
private void Home_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F1) { MessageBox.Show("F1 key Pressed"); } }