Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine if Shift Key is Pressed

Status
Not open for further replies.

pembroke

Programmer
May 14, 2002
1
US
I want to be able to determine if the Shift Key is pressed entirely in code, without using the keydown/up (etc.) events in MS Access 2000. There are many times I want to execute code only of the Shift key is pressed, such as when using the NodeClick property of a Tree View control. Is this possible?
 
Hi

You have to use the GetKeyState API function.


Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

' Constants for the shift keys
Const VK_SHIFT As Integer = &H10


Sub DisplayKeyStatus()

' Use API calls to determine shift keys are pressed
If GetKeyState(VK_SHIFT) < 0 Then Shift = True Else Shift = False

Msg = &quot;Shift key press? :&quot; & Shift

MsgBox Msg, vbInformation, &quot;Message&quot;
End Sub


Hope this helps.

LSTAN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top