tauri-plugin-prevent-default
Disable default browser shortcuts in your Tauri app, e.g. F3
or Ctrl+J
.
Install
Install the plugin by adding the following to your Cargo.toml
file:
[]
= "3"
Usage
Register the plugin with Tauri:
src-tauri/src/main.rs
.plugin
.run
.expect;
default
You can also use flags to determine which shortcuts the plugin should disable. By default, it will disable all of them.
use Flags;
let prevent = new
.with_flags
.build;
default
.plugin
.run
.expect;
If you want to keep only CONTEXT_MENU
, DEV_TOOLS
, and RELOAD
enabled in dev mode, you can build the plugin with tauri_plugin_prevent_default::debug
instead.
.plugin
.run
.expect;
default
Examples
- Disable all but a few:
use Flags;
// This will disable all shortcuts, except `FIND` and `RELOAD`.
new
.with_flags
.build
- Disable only keyboard shortcuts:
use Flags;
new
.with_flags
.build
- Disable custom shortcuts:
use KeyboardShortcut;
use ;
new
.shortcut
.shortcut
.shortcut
.build;
- Keep certain shortcuts enabled only when in dev mode:
Platform-specific options
Please read our versioning policy before using any of these options.
Windows
The platform-windows
feature must be enabled.
[]
= { = "3", = ["platform-windows"] }
use PlatformOptions;
new
.platform
.build
Versioning and Experimental Features
This plugin adheres to SemVer. However, features marked as unstable
are experimental and may introduce breaking changes between minor versions.
Supported Tauri Version
This plugin requires Tauri 2.0
or later.