How do I trap Control key held down in mouse click event handler

Jul 24, 2012 at 9:09 PM

The mouse click event handler has EventArgs as a second parameter.  Is there a way to find out how to trap Control+Click from within the mouse click event handler?

Jul 26, 2012 at 3:04 PM
            KeyStateInfo ctrlKey = KeyboardInfo.GetKeyState(Keys.ControlKey);
            if (ctrlKey.IsPressed)

Jul 26, 2012 at 10:31 PM
Edited Jul 26, 2012 at 10:32 PM

I am not sure what namespace one must define and which references one must add to a project, but a search did not turn up KeyStateInfo or KeyboardInfo.  There is the Win32 API KeyStateInfo, but there usually is a .Net way.

After some pain and suffering given Joe's code and his comment to look at the existing key state using Windows and trying to locate that on Google, the following works too:

if (0 != (Control.ModifierKeys & Keys.Control))
     whatever here;

It The other possible key to trap and use is the shift.  Shift+Click and Control+Click for selecting rows are the two most common.