Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Catching keyevents
#16
(2023-01-05, 11:00:10)hsacrm Wrote: Hello Wil,

I've tried the latest build. It works perfectly fine. Thanks.

These aren't issues for me anymore, just wanted to tell my observation if anyone has the same problems in the future:
- As long as you press down a key, the event will be called an endless time. So make sure your code is compatible with this.
- IsShiftKeyDown and IsControlKeyDown will always return 0 if you release it.
This means you cannot do a check like `if keyreleased then` because you won't know anymore if the accelatorkeys were pressed. So when pressing or holding down ctrl + shift + x, IsControlKeyDown and IsShiftKeyDown will return 1. Releasing it will show 0 even if you check whether the x-key was pressed on release.
- You cannot debug manually  in VBA, the code will simply stop executing at a breakpoint as if it's never called. Debug by using print-statements. It probably has something to do with that the browser is async.

Glad to hear it works for you.

The code was tested on key-up, not key down. Even on key-up the shift and control modifiers still showed as "down".
For IsShiftKeyDown and IsControlKeyDown I figured to use a similar interface as WebView2's CoreWebView2PhysicalKeyStatus interface. So the return data type is integer and it returns 1 instead of using booleans.

One difference though is that -since I'm using the GetKeyState API- is that the function IsShiftKeyDown/IsControlKeyDown test the moment you query them.
This means that if you would run in a debug session and set a breakpoint that the status of these keys are showing the key status from your debug session. Not the status from before the breakpoint triggers.
Perhaps this can be handled, but certainly not now as I'm very close to a release and don't want to risk breaking things.
I have updated the documentation to mention that tidbit as it is an important difference.
--
Wil
Reply


Messages In This Thread
Catching keyevents - by hsacrm - 2022-12-29, 13:39:15
RE: Catching keyevents - by wila - 2022-12-29, 14:07:06
RE: Catching keyevents - by hsacrm - 2022-12-29, 15:20:45
RE: Catching keyevents - by wila - 2022-12-29, 18:43:07
RE: Catching keyevents - by hsacrm - 2023-01-02, 08:21:44
RE: Catching keyevents - by wila - 2023-01-02, 11:50:42
RE: Catching keyevents - by wila - 2023-01-02, 13:18:59
RE: Catching keyevents - by hsacrm - 2023-01-02, 14:29:06
RE: Catching keyevents - by wila - 2023-01-02, 15:03:32
RE: Catching keyevents - by hsacrm - 2023-01-04, 14:34:38
RE: Catching keyevents - by wila - 2023-01-04, 14:50:29
RE: Catching keyevents - by hsacrm - 2023-01-04, 15:43:49
RE: Catching keyevents - by wila - 2023-01-04, 17:05:43
RE: Catching keyevents - by wila - 2023-01-04, 17:34:32
RE: Catching keyevents - by hsacrm - 2023-01-05, 11:00:10
RE: Catching keyevents - by wila - 2023-01-05, 11:39:41
RE: Catching keyevents - by hsacrm - 2023-01-05, 12:50:00
RE: Catching keyevents - by wila - 2023-01-05, 16:28:34
RE: Catching keyevents - by hsacrm - 2023-01-06, 07:39:15

Forum Jump:


Users browsing this thread: 1 Guest(s)