Below is the code for Ctrl + F (from another SO post). But how do you detect a Ctrl + ForwardSlash? or Ctrl + / (note: divide does not work)
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (1 == 1) //keyData == (Keys.Control | Keys.F))
{
MessageBox.Show("What the Ctrl+F?");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
Divide should work fine.
For Ctrl + \:
if (keyData == (Keys.Control | Keys.OemPipe) )
For Ctrl + /:
if (keyData == (Keys.Control | Keys.OemQuestion) )
For some reason (not sure why), when you trap Ctrl + these keys, they're mapping to the "shifted" keymappings.
Edit:
One trick for finding this, or any other key. Set a breakpoint on any line in that method, and look at the keyData
value when you press the key you're trying to trap. I recommend doing this without hitting control. You can then use reflector to get all of the specific values for Keys
, and find the "key" with the appropriate value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With