Connecting Tech Pros Worldwide Forums | Help | Site Map

Capturing Modifier Keys in ProcessCmdKey Event

Phil Galey
Guest
 
Posts: n/a
#1: Nov 21 '05
I'm using the ProcessCmdKey event to capture various keys that are pressed.
However, I'm having trouble capturing the combination of the CTRL key and,
say, the DOWN key. If I just press the CTRL key alone, the KeyData value is
131089. But all the possibilities I'm finding in the Keys enumeration are
the following:

Keys.ControlKey = 17
Keys.Control = 131072
Keys.LControlKey = 162
Keys.RControlKey = 163

Question:
How would I capture when the user presses the CTRL key at the left end of
the keyboard together with the DOWN arrow?

I've tried

If KeyData = Keys.Down & <each of those listed above> Then
'
'
'
End IF

and have also tried a logical 'And'. Nothing seems to work so far. Thanks.



AMDRIT
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Capturing Modifier Keys in ProcessCmdKey Event


See if this helps

http://msdn.microsoft.com/library/de...isualBasic.asp




"Phil Galey" <pagaley@starcalif.com.nospam> wrote in message
news:OxuayaGxFHA.1168@TK2MSFTNGP15.phx.gbl...[color=blue]
> I'm using the ProcessCmdKey event to capture various keys that are
> pressed.
> However, I'm having trouble capturing the combination of the CTRL key and,
> say, the DOWN key. If I just press the CTRL key alone, the KeyData value
> is
> 131089. But all the possibilities I'm finding in the Keys enumeration are
> the following:
>
> Keys.ControlKey = 17
> Keys.Control = 131072
> Keys.LControlKey = 162
> Keys.RControlKey = 163
>
> Question:
> How would I capture when the user presses the CTRL key at the left end of
> the keyboard together with the DOWN arrow?
>
> I've tried
>
> If KeyData = Keys.Down & <each of those listed above> Then
> '
> '
> '
> End IF
>
> and have also tried a logical 'And'. Nothing seems to work so far.
> Thanks.
>
>[/color]


Dennis
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Capturing Modifier Keys in ProcessCmdKey Event


It may be a crude solution, but you can set a form variable and in the
KeyDown and keyup events, toggle a boolean variable to indicate if the
control key is pressed when one of the other keys is caught by ProcessCmdKey.
--
Dennis in Houston


"Phil Galey" wrote:
[color=blue]
> I'm using the ProcessCmdKey event to capture various keys that are pressed.
> However, I'm having trouble capturing the combination of the CTRL key and,
> say, the DOWN key. If I just press the CTRL key alone, the KeyData value is
> 131089. But all the possibilities I'm finding in the Keys enumeration are
> the following:
>
> Keys.ControlKey = 17
> Keys.Control = 131072
> Keys.LControlKey = 162
> Keys.RControlKey = 163
>
> Question:
> How would I capture when the user presses the CTRL key at the left end of
> the keyboard together with the DOWN arrow?
>
> I've tried
>
> If KeyData = Keys.Down & <each of those listed above> Then
> '
> '
> '
> End IF
>
> and have also tried a logical 'And'. Nothing seems to work so far. Thanks.
>
>
>[/color]
Closed Thread