Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shift key not recognized when focus is changed to QB64 program
#1
Is the _KeyDown command (in regards to the SHIFT key) only recognizing a change in state rather than reading the position of the key?  Run the following program:

Code: (Select All)
Common Shared true%, false%

true% = (1 = 1): false% = (1 = 0)


start:
Locate 10, 10
If Shiftpressed% Then Print "YES" Else Print "NO "
If InKey$ = Chr$(27) Then System
GoTo start


Function Shiftpressed%
    'returns true% if either SHIFT key is pressed
    If _KeyDown(100303) + _KeyDown(100304) = 0 Then
        Shiftpressed% = false%
    Else
        Shiftpressed% = true%
    End If
End Function



Press and release shift - everything works great.
     Click on another window other than the running QB64 program.
     Press and hold the shift key.
     Click on the running QB64 program

The state never changes to YES until you cycle the shift key.  I am guessing that the state of the key is not actually being read, but rather a change in state while the QB64 program is the active window is required?

I am unsure how to get around this, but if anyone has any ideas how I can accurately register the state of a key when reentering a QB64 program it would be greatly appreciated.
Reply


Messages In This Thread
Shift key not recognized when focus is changed to QB64 program - by dano - 09-15-2024, 01:26 PM



Users browsing this thread: 13 Guest(s)