Compartir a través de


WebView2CompositionControl.OnKeyDown(KeyEventArgs) Method

Definition

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:

  1. CoreWebView2Controller_AcceleratorKeyPressed
  2. PreviewKeyDownEvent
  3. KeyDownEvent
  4. 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)

Parameters

Applies to