How to detect Ctrl - Forward Slash in WinForm app
.net, c#, keyboard-shortcuts, winforms
Solution
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.
Problem
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); } ```