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:
[]
= 1.0
If using custom listeners, you must also enable the required permissions:
src-tauri/capabilities/prevent-default.json
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;
- 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
Windows
The unstable-native-windows
feature must be enabled.
[]
= { = "1.0", = ["unstable-native-windows"] }
// Whether general form information should be saved and autofilled.
// Defaults to `true`.
.general_autofill
// Whether password information should be autosaved.
// Defaults to `false`.
.password_autosave
.build
new
Experimental features
Cargo features prefixed with unstable-
are experimental and may introduce breaking changes between patch versions or even be completely removed.
Note
The plugin should work fine on Windows, but there are still tests to be done on MacOS and Linux. If you encounter any problems on these platforms, please open an issue.
Supported Tauri Version
This plugin requires Tauri 2.0
or later.