Shift key down

Carrie
07-19-2003, 05:38 AM
I need to be able to tell if the user has the shift key down when clicking on a grid line as click no shift will be select and click +shift key will un-select but not sure how I tell if shift is down whilst in the click event.

Kashif
07-19-2003, 05:49 AM
I need to be able to tell if the user has the shift key down when clicking on a grid line as click no shift will be select and click +shift key will un-select but not sure how I tell if shift is down whilst in the click event.


Select Case KeyCode
Case vbKeyUp 'check the event which you want
If Shift = vbCtrlMask Then ' it willcheck the SHIFT key is pressed
' can write the statments
End If
End Select

this code will be written in the KeyDown Event...

passel
07-19-2003, 06:34 AM
I need to be able to tell if the user has the shift key down when clicking on a grid line as click no shift will be select and click +shift key will un-select but not sure how I tell if shift is down whilst in the click event.

The Shift key code is passed to the MouseDown event, so you can check it the shift key is pressed when the mouse is clicked.

The value will be 0 if no shift type key is pressed.
The value will be 1 if the shift key is pressed
The value will be 2 if the Ctrl key is pressed
The value will be 4 if the Alt key is pressed
The value will be the sum of 1, 2 and/or 4 if multiple keys are pressed.
i.e., the value will be 7 if all three keys are pressed togther when you
click the mouse.

This also applies to the MouseMove and MouseUp events, so you can
add special processing in those conditions as well, i.e. Is the shift key being held in the drag, or is it released.
An example may be if someone's hand is a little unsteady and they tend
to move the mouse when they try and click on a point. You could
monitor the shift in the mouse move, and if they press the shift, then you start processing just as if they had clicked the mouse and were
dragging, once the shift is released, you stop processing like you were
dragging, you never had to press a mouse button (just an example, not
necessarily something you would want to do).

manavo
07-19-2003, 08:22 PM
ShiftTest = Shift And 7
Select Case ShiftTest
Case 1
Debug.Print "Shift"
Case 2
Debug.Print "Ctrl"
Case 4
Debug.Print "Alt"
Case 3
Debug.Print "Shift + Ctrl"
Case 5
Debug.Print "Shift + Alt"
Case 6
Debug.Print "Ctrl + Alt"
Case 7
Debug.Print "Shift + Ctrl + Alt"
End Select

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum