CoreWebView2AcceleratorKeyPressedEventArgs Class
Event args for the CoreWebView2Controller.AcceleratorKeyPressed event.
Summary
Members | Description |
---|---|
Handled | Indicates whether the CoreWebView2Controller.AcceleratorKeyPressed event is handled by host. |
IsBrowserAcceleratorKeyEnabled | This IsBrowserAcceleratorKeyEnabled property allows developers to control whether the browser handles accelerator keys such as Ctrl+P or F3, etc. |
KeyEventKind | Gets the key event kind that caused the event to run. |
KeyEventLParam | Gets the LPARAM value that accompanied the window message. |
PhysicalKeyStatus | Gets a CoreWebView2PhysicalKeyStatus representing the information passed in the LPARAM of the window message. |
VirtualKey | Gets the Win32 virtual key code of the key that was pressed or released. |
Properties
Handled
bool Handled
Indicates whether the CoreWebView2Controller.AcceleratorKeyPressed event is handled by host.
For browser accelerator keys, when an accelerator key is pressed, the propagation and processing order is:
- A CoreWebView2Controller.AcceleratorKeyPressed event is raised
- WebView2 browser feature accelerator key handling
- Web Content Handling: If the key combination isn't reserved for browser actions, the key event propagates to the web content, where JavaScript event listeners can capture and respond to it.
If Handled
property is set to true
anywhere along the path, the event propagation stops, and web content will not receive the key and this prevents the WebView from performing the default action for this accelerator key. Otherwise the WebView will perform the default action for the accelerator key.
IsBrowserAcceleratorKeyEnabled
bool IsBrowserAcceleratorKeyEnabled
This IsBrowserAcceleratorKeyEnabled
property allows developers to control whether the browser handles accelerator keys such as Ctrl+P or F3, etc.
The CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled
API is a convenient setting for developers to disable all the browser accelerator keys together. This setting also sets the default value for the IsBrowserAcceleratorKeyEnabled
property.
By default, CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled
is TRUE
and IsBrowserAcceleratorKeyEnabled
is TRUE
. When developers change CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled
setting to FALSE
, this will change default value for IsBrowserAcceleratorKeyEnabled
to FALSE
. If developers want specific keys to be handled by the browser after changing the CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled
setting to FALSE
, they need to enable these keys by setting IsBrowserAcceleratorKeyEnabled
to TRUE
.
The CoreWebView2Controller.AcceleratorKeyPressed
event is raised any time an accelerator key is pressed, regardless of whether accelerator keys are enabled or not.
This API will give the event arg higher priority over the CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled
setting when we handle the keys.
With IsBrowserAcceleratorKeyEnabled
property, if developers mark IsBrowserAcceleratorKeyEnabled
as FALSE
, the browser will skip the WebView2 browser feature accelerator key handling process, but the event propagation continues, and web content will receive the key combination.
This property does not disable accelerator keys related to movement and text editing, such as:
- Home, End, Page Up, and Page Down
- Ctrl-X, Ctrl-C, Ctrl-V
- Ctrl-A for Select All
- Ctrl-Z for Undo
KeyEventKind
readonly CoreWebView2KeyEventKind KeyEventKind
Gets the key event kind that caused the event to run.
KeyEventLParam
readonly int KeyEventLParam
Gets the LPARAM value that accompanied the window message.
See the documentation for the WM_KEYDOWN
and WM_KEYUP
messages.
PhysicalKeyStatus
readonly CoreWebView2PhysicalKeyStatus PhysicalKeyStatus
Gets a CoreWebView2PhysicalKeyStatus representing the information passed in the LPARAM of the window message.
VirtualKey
readonly uint32_t VirtualKey
Gets the Win32 virtual key code of the key that was pressed or released. It is one of the Win32 virtual key constants such as VK_RETURN or an (uppercase) ASCII value such as 'A'. Verify whether Ctrl or Alt are pressed by running GetKeyState(VK_CONTROL) or GetKeyState(VK_MENU).