共用方式為


CoreWebView2Settings.AreBrowserAcceleratorKeysEnabled Property

Definition

Determines whether browser-specific accelerator keys are enabled.

public bool AreBrowserAcceleratorKeysEnabled { get; set; }
member this.AreBrowserAcceleratorKeysEnabled : bool with get, set
Public Property AreBrowserAcceleratorKeysEnabled As Boolean

Property Value

Examples

_allowWebViewShortcutKeys = value;
if (_iWebView2.CoreWebView2 != null)
{
    WebViewSettings.AreBrowserAcceleratorKeysEnabled = value;
}
else if (!_allowShortcutsEventRegistered)
{
    _allowShortcutsEventRegistered = true;
    _iWebView2.CoreWebView2InitializationCompleted += (sender, e) =>
    {
        if (e.IsSuccess)
        {
            WebViewSettings.AreBrowserAcceleratorKeysEnabled = _allowWebViewShortcutKeys;
        }
    };
}

Remarks

When this setting is set to false, it disables all accelerator keys that access features specific to a web browser, including but not limited to:

- Ctrl+F and F3 for Find on Page - Ctrl+P for Print - Ctrl+R and F5 for Reload - Ctrl+Plus and Ctrl+Minus for zooming - Ctrl+Shift-C and F12 for DevTools - Special keys for browser functions, such as Back, Forward, and Search

It 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

Those accelerator keys will always be enabled unless they are handled in the AcceleratorKeyPressed event.

This setting has no effect on the AcceleratorKeyPressed event. The event will be fired for all accelerator keys, whether they are enabled or not.

The default value of AreBrowserAcceleratorKeysEnabled is true.

Applies to

See also