Shift key not recognized when focus is changed to QB64 program - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2) +--- Thread: Shift key not recognized when focus is changed to QB64 program (/showthread.php?tid=3037) Pages:
1
2
|
RE: Shift key not recognized when focus is changed to QB64 program - SMcNeill - 09-17-2024 My keyboard library works fine with it in windows. It's all incorporated into my toolkit now. https://github.com/SteveMcNeill/QB64-Phoenix-Edition-Toolbox RE: Shift key not recognized when focus is changed to QB64 program - DSMan195276 - 09-17-2024 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. RE: Shift key not recognized when focus is changed to QB64 program - TerryRitchie - 09-17-2024 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. RE: Shift key not recognized when focus is changed to QB64 program - SMcNeill - 09-17-2024 (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. RE: Shift key not recognized when focus is changed to QB64 program - Pete - 09-17-2024 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 RE: Shift key not recognized when focus is changed to QB64 program - TerryRitchie - 09-18-2024 (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. RE: Shift key not recognized when focus is changed to QB64 program - Pete - 09-18-2024 @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 RE: Shift key not recognized when focus is changed to QB64 program - TerryRitchie - 09-18-2024 (09-18-2024, 03:09 AM)Pete Wrote: @TerryRitchieWhat a simple solution. Thanks Pete |