WebView2CompositionControl.OnKeyDown(KeyEventArgs) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This is overridden from UIElement and called to allow us to handle key press input. WPF should never actually call this in response to keyboard events because the focus is on the controller's HWND. When Controller's HWND has focus, WPF does not know the Controller's HWND belongs to this control, and the key event will not be fired for this control and WPF main window. This override should only be called when we're explicitly forwarding accelerator key input from the CoreWebView2 to WPF (in CoreWebView2Controller_AcceleratorKeyPressed). Even then, this KeyDownEvent is only triggered because our PreviewKeyDownEvent implementation explicitly triggers it, matching WPF's usual system. So the process is:
- CoreWebView2Controller_AcceleratorKeyPressed
- PreviewKeyDownEvent
- KeyDownEvent
- OnKeyDown
protected override void OnKeyDown (System.Windows.Input.KeyEventArgs e);
override this.OnKeyDown : System.Windows.Input.KeyEventArgs -> unit
Protected Overrides Sub OnKeyDown (e As KeyEventArgs)