Working with the event for the KeyUp event handler will work.
The following code runs when you release the Ctrl key:
private void Form1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.ControlKey) { MessageBox.Show("Control key up"); } }
If you want to check whether Ctrl was pressed in combination with another keystroke, for example: Ctrl + F1 , the following code fragment may be required:
private void Form1_KeyUp(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.F1) { MessageBox.Show("Control + F1 key up"); } }
Note: you may need to enable KeyPreview on the form to catch all KeyPreview control events in one place.
source share