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:
[]
= 0.2
Enable the required permissions:
src-tauri/capabilities/prevent-default.json
OPTIONAL: Install the JavaScript package with your preferred package manager:
Installing the JavaScript package is completely optional. Its only purpose is to provide a way to set simple listeners using JavaScript.
event:allow-listen
should be added to the capabilities file if you decide to use it.
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
.build;
Set a custom event listener:
use Flags;
new
.on_flag_event
.build;
Keep certain shortcuts enabled only when in dev mode:
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.
Contributing
If there is any other shortcuts that I can include in the plugin, please let me know!