@TerryRitchie
This uses your routine with Win32 added. It will detect Shift key down when your return focus to the window.
1) Run program.
2) Click your desktop to take away focus.
3) Hold a shift key down.
4) Click your QB64 window to return focus while still holding down the shift key.
Pete
This uses your routine with Win32 added. It will detect Shift key down when your return focus to the window.
1) Run program.
2) Click your desktop to take away focus.
3) Hold a shift key down.
4) Click your QB64 window to return focus while still holding down the shift key.
Code: (Select All)
Declare Dynamic Library "user32"
Function GetAsyncKeyState% (ByVal vkey As Long)
End Declare
Locate 8, 2
Print "NOTE: _KEYDOWN only registers SHIFT keys and some of the other keyboard keys"
Print " _KEYDOWN will register multiple keys"
Print " A negative _KEYHIT value means the key was released"
Do
Locate 2, 2
If _WindowHasFocus Then
'IF focus = 0 THEN _KEYCLEAR
focus = -1
Print "WINDOW HAS FOCUS "
Else
focus = 0
Print "WINDOW DOES NOT HAVE FOCUS"
End If
a$ = InKey$
Locate 4, 2
Print "INKEY$ = "; a$
Locate 5, 2
Print "_KEYHIT = ";
k = _KeyHit
If k <> 0 Then Print k; " "
Locate 6, 2
Print "_KEYDOWN = ";
If _KeyDown(100304) And _KeyDown(100303) Then
Print "LEFT & RIGHT SHIFT"
ElseIf _KeyDown(100304) Or focus = -1 And GetAsyncKeyState(160) Then ' <--------------------
Print "LEFT SHIFT "
ElseIf _KeyDown(100303) Or focus = -1 And GetAsyncKeyState(161) Then ' <--------------------
Print "RIGHT SHIFT "
Else
For k = 33 To 122
If _KeyDown(k) Then
Print Chr$(k); " "; ' print multiple keys
End If
Next k
Print " "
End If
_Limit 60
Loop Until _KeyDown(27)
Pete
Shoot first and shoot people who ask questions, later.