how can i run a method when someone user a keyboard shortcuts like CTRL + G ?
the application is a Windows forms application and i only want to capture them when the form is activated.
how can i run a method when someone user a keyboard shortcuts like CTRL + G ?
the application is a Windows forms application and i only want to capture them when the form is activated.
Look at your OnKeyPress method on the Form or the KeyPress event for the Form.
Override the OnKeyPress like this...
protected override void OnKeyPress(KeyPressEventArgs e) { ... }
... and look at the KeyPressEventArgs to see what key was pressed and whether it was pressed with Ctrl.
This SO answer shows how to use the KeyPress event... http://stackoverflow.com/questions/1143567/test-for-ctrl-keydown
Keyboard shortcuts are often referred to as "command keys". If you want first-crack at keypresses (before your child controls), the best place is to override the ProcessCmdKey method on your form.