Detect Shift key in Ctrl-Shift-O in KeyDown event
I am trying to circumvent the problem that the WebView2 control doesn’t behave like the WebBrowser control for hot keys/keyboard short cuts/key forwarding that is described in
https://github.com/MicrosoftEdge/WebView2Feedback/issues/468
I’m using the WebView2 keydown event and I can detect Ctrl and Alt but I can’t detect Shift in sequences like Ctrl-Shift-O (I can detect the Ctrl and the O)
As far as I can tell none of the KeyEventArgs (Modifiers, KeyData or Shift) are set to indicate that Shift has been pressed.
Is there currently anyway of detecting Shift?
Hey @JimWard2018 - Shift should be coming in as a KeyDown, similar to Ctrl. You are correct that it doesn't currently populate the KeyEventArgs as expected. We are beginning work that will improve this experience and better integrate with the .NET frameworks. Thanks!
@champnic It currently isn't coming in like Ctrl; when do you expect this work to be completed so that it is?
Aha you are right - I'm going to reopen this. The main work will be over the next few months.
In the meantime, the instructions here seem to work for me (using VK_SHIFT=0x10;):
https://stackoverflow.com/questions/3829725/winforms-retrieve-keyboard-state-without-form-usercontrol
That worked perfectly. Thank you @champnic
Glad you got it working! I've opened this as a bug on our backlog to track making sure we fix this in the future.
@champnic I'm seeing they KeyUp doesn't fire when the ShiftKey is released, but fires for Alt and Control. Is this related to this issue, or should I open a new one? It's causing issues with some custom hotkey handling I'm doing
Seems like the msWebView2BrowserHitTransparent feature flag helps here but it also makes Tab stop working. It doesn't move focus. Maybe I need to do some preprocessing and let it through? Not sure
Also, seems like Enter also doesn't trigger KeyUp