devxlogo

KeysPressed – Test the status of up to three keys

KeysPressed – Test the status of up to three keys

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As _    Integer' Return True if all the specified keys are pressed'' you can specify individual keys using VB constants, ' e.g. If KeysPressed(vbKeyControl, vbKeyDown) Then ...Function KeysPressed(ByVal KeyCode1 As KeyCodeConstants, _    Optional ByVal KeyCode2 As KeyCodeConstants, Optional ByVal KeyCode3 As _    KeyCodeConstants) As Boolean    If GetAsyncKeyState(KeyCode1) >= 0 Then Exit Function    If KeyCode2 = 0 Then KeysPressed = True: Exit Function    If GetAsyncKeyState(KeyCode2) >= 0 Then Exit Function    If KeyCode3 = 0 Then KeysPressed = True: Exit Function    If GetAsyncKeyState(KeyCode3) >= 0 Then Exit Function    KeysPressed = TrueEnd Function

devx-admin

Share the Post: