Re: Trap Modifier Key

samir parekh <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
Hi Phil,

Use the static Control.ModifierKeys to determine if control keys are down
 at any given time.

so, on the button.click event use the following piece of code...

 if(Control.ModifierKeys == Keys.Control) // only the CTRL key is pressed

 if(( Control.ModifierKeys & Keys.Control) != 0) // CTRL key is pressed,
 though ALT or SHIFT may be pressed as well


Regards
Samir



Phil Sayers <[email protected]> wrote: I want to add functionality to one of my forms,

if a button is clicked while the user is holding down the Ctrl and the Shift
key, i want to display a bunch of debugging/trace information, as well as
performing the default action (which is already coded).

So my question is: how do i detect which modifier keys are held down in a
button click event handler?  Is there a trick to this, or am I going to have
to tie into KeyDown event and set a flag,  resetting the flag on KeyUp ?

Thanks



---------------------------------
Building a website is a piece of cake.
Yahoo! Small Business gives you all the tools to get online.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.