My keyboard library works fine with it in windows. It's all incorporated into my toolkit now.
https://github.com/SteveMcNeill/QB64-Pho...on-Toolbox
https://github.com/SteveMcNeill/QB64-Pho...on-Toolbox
Shift key not recognized when focus is changed to QB64 program
|
My keyboard library works fine with it in windows. It's all incorporated into my toolkit now.
https://github.com/SteveMcNeill/QB64-Pho...on-Toolbox
09-17-2024, 08:55 PM
Something to note, on Windows the Shift keys are special/bugged, I think that's part of what you're seeing and probably why _KeyDown doesn't report it in this case. I put in a bug fix for the shift keys a while back that applies to _Devices, that's why it's always correct, in that case it uses GetAsyncKeyState to check the shift keys rather than relying on the WM_KEYDOWN and WM_KEYUP messages.
In regards to keyboard state when not in focus, in theory I don't think we should see any keys when the window loses focus but they should appear as pressed when the window regains focus if they were held down. GetAsyncKeyState does allow you to see the keys at all times on Windows, I believe. On Linux and potentially Mac OS that's not always allowed for security reasons though, so it's not really something you can reliably implement in a platform-independent way.
09-17-2024, 08:59 PM
Well _BUTTON does work as I showed previously so there is a way to work with it. I'm assuming Steve's library uses _BUTTON as well. That's also what I used for my controller library which picks up the keys just fine too.
09-17-2024, 09:54 PM
(09-17-2024, 08:59 PM)TerryRitchie Wrote: Well _BUTTON does work as I showed previously so there is a way to work with it. I'm assuming Steve's library uses _BUTTON as well. That's also what I used for my controller library which picks up the keys just fine too. What I wrote predates the _DEVICES and _BUTTON fixes, so it relies on the Windows APIs that Matt mentioned in the post before yours. That's why it's a Windows-Only expansion to _KeyHit, and doesn't work on all platforms.
09-17-2024, 11:41 PM
Same here, for my multi-windows programs where I use Windows products to communicate with an open QB64 window, I always use a Win32 API method I coded for mouse and squirrel, I mean keyboard.
Pete
Fake News + Phony Politicians = Real Problems
09-18-2024, 12:47 AM
(09-17-2024, 09:54 PM)SMcNeill Wrote:Oh, I'll need to take a look at that. I played with a few API calls a long while back and didn't get very far with them.(09-17-2024, 08:59 PM)TerryRitchie Wrote: Well _BUTTON does work as I showed previously so there is a way to work with it. I'm assuming Steve's library uses _BUTTON as well. That's also what I used for my controller library which picks up the keys just fine too.
@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. Code: (Select All)
Pete
Fake News + Phony Politicians = Real Problems
09-18-2024, 03:15 AM
(09-18-2024, 03:09 AM)Pete Wrote: @TerryRitchieWhat a simple solution. Thanks Pete |
« Next Oldest | Next Newest »
|