08-09-2022, 02:52 AM
Trying to get my tiny brain around the _keyhit command... It seems to switch to the negative key value when the key is released, but with this simple piece, it seems to have retained its positive value. Where am I going wrong?
Code: (Select All)
Color 0, 15: Cls
Message:
k = 0 ' I need this because _keyhit retains its positive (key pressed) value
Print "Press A or B"
Do Until k > 0 ' do this until _keyhit is positive
k = _KeyHit ' set k to _keyhit value
Loop
' now leave loop with k set at positive value from _keyhit
Select Case k
Case Is = 65, 97 ' "A" pressed
ResponseA
Case Is = 66, 98 ' "B" pressed
ResponseB
Case Else
WrongKey
End Select
Cls
GoTo Message
Sub ResponseA
Print "A pressed"
Sleep 1
End Sub
Sub ResponseB
Print "B pressed"
Sleep 1
End Sub
Sub WrongKey
Print "Wrong Key!"
Sleep 1
End Sub