Checking for "Control key" pressed

  • Thread starter Thread starter DP
  • Start date Start date
D

DP

I don't know how to "trap" or check for the control key being pressed and
kept down / and released.

Is there a simple code snippet that could be attached to some other control
to check if the control key is down so that certain code will run (if it's
down), and not run if it's not down?

Thanks.

DP
 
Check out the KeyDown event. It has a parameter named 'shift'. To determine
whether the Control Key is pressed you need to check the value of the Shift
parameter. To do this you do a
bitwise AND with the appropriate mask to determine which of the Ctl, Alt &
Shift keys are down.

Dim fShift As Boolean 'True when Shift key is down
Dim fAlt As Boolean 'True when Alt key is down
Dim fCtl As Boolean 'True when Ctl key is down
fShift = Shift And acShiftMask
fAlt = Shift And acAltMask
fCtl = Shift And acCtrlMask

With this you can do your comparison:

if fShift then
msgbox "Control key is down
endif
 
Thank you!

Now if I can just figure out how to "trap" whether the mouse wheel is "going
up" or "going down," I'll be in business.

David Pike

Sandra Daigle said:
Check out the KeyDown event. It has a parameter named 'shift'. To determine
whether the Control Key is pressed you need to check the value of the Shift
parameter. To do this you do a
bitwise AND with the appropriate mask to determine which of the Ctl, Alt &
Shift keys are down.

Dim fShift As Boolean 'True when Shift key is down
Dim fAlt As Boolean 'True when Alt key is down
Dim fCtl As Boolean 'True when Ctl key is down
fShift = Shift And acShiftMask
fAlt = Shift And acAltMask
fCtl = Shift And acCtrlMask

With this you can do your comparison:

if fShift then
msgbox "Control key is down
endif



--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I don't know how to "trap" or check for the control key being pressed
and kept down / and released.

Is there a simple code snippet that could be attached to some other
control to check if the control key is down so that certain code will
run (if it's down), and not run if it's not down?

Thanks.

DP
 
Back
Top