Partager via


WebView2.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 we're hosting a non-WPF window. When our window has focus Windows will send the input directly to it rather than to WPF's top-level window and input system. 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