-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any way for WebView2 to detect the KeyDown the same as the MainWindow? #536
Comments
You could use the power of Javascript, although it might not be reliable at all times (e.g when a page is still loading). You can use the function AddScriptToExecuteOnDocumentCreatedAsync to inject the code to listen for "keydown" and then listen for this message using the WebMessageReceived event. Try this: and create a function called "MaximizeFunction", or simply rename it, with your maximize/restore code you already have. I can't try the code at the moment as there is a problem with Edge Canary. There are more reliable ways like a keyboard hook, but then you'd also need to check if edge is focused, and if you have multiple windows you'd need to check the handles for each window, it gets rather complicated. |
As others have mentioned, please try the javascript workaround for now. We are tracking better keyboard support as @G33kDude mentioned, so I'm going to close this issue. Please reply if those issues don't cover your scenario, the workaround isn't working for you, or you'd like me to reopen for another reason. Thanks! |
Noting for others that end up here via search: as of version 1.0.1264.42, the WPF version of WebView2 has support for Key events (via methods like |
Hi,
I have a function on the MainWindow that makes the window Maximized when I press the Keyword "T".
Everything works fine until I click with my mouse or set focus on the WebView2, then it stopped working altogether.
Is there any way for WebView2 to detect the KeyDown the same as the MainWindow?
The text was updated successfully, but these errors were encountered: