mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-05-27 13:22:26 +02:00
docs(global-shotcut): update docs in README and ts files (#1291)
This commit is contained in:
@@ -63,12 +63,14 @@ fn main() {
|
||||
app.handle().plugin(
|
||||
tauri_plugin_global_shortcut::Builder::new()
|
||||
.with_shortcuts(["ctrl+d", "alt+space"])?
|
||||
.with_handler(|app, shortcut| {
|
||||
if shortcut.matches(Modifiers::CONTROL, Code::KeyD) {
|
||||
let _ = app.emit("shortcut-event", "Ctrl+D triggered");
|
||||
}
|
||||
if shortcut.matches(Modifiers::ALT, Code::Space) {
|
||||
let _ = app.emit("shortcut-event", "Alt+Space triggered");
|
||||
.with_handler(|app, shortcut, event| {
|
||||
if event.state == ShortcutState::Preseed {
|
||||
if shortcut.matches(Modifiers::CONTROL, Code::KeyD) {
|
||||
let _ = app.emit("shortcut-event", "Ctrl+D triggered");
|
||||
}
|
||||
if shortcut.matches(Modifiers::ALT, Code::Space) {
|
||||
let _ = app.emit("shortcut-event", "Alt+Space triggered");
|
||||
}
|
||||
}
|
||||
})
|
||||
.build(),
|
||||
@@ -86,8 +88,10 @@ Afterwards all the plugin's APIs are available through the JavaScript bindings:
|
||||
|
||||
```javascript
|
||||
import { register } from "@tauri-apps/plugin-global-shortcut";
|
||||
await register("CommandOrControl+Shift+C", () => {
|
||||
console.log("Shortcut triggered");
|
||||
await register("CommandOrControl+Shift+C", (event) => {
|
||||
if (event.state === "Pressed") {
|
||||
console.log("Shortcut triggered");
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -23,8 +23,10 @@ export type ShortcutHandler = (event: ShortcutEvent) => void;
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { register } from '@tauri-apps/plugin-global-shortcut';
|
||||
* await register('CommandOrControl+Shift+C', () => {
|
||||
* console.log('Shortcut triggered');
|
||||
* await register('CommandOrControl+Shift+C', (event) => {
|
||||
* if (event.state === "Pressed") {
|
||||
* console.log('Shortcut triggered');
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
@@ -51,8 +53,8 @@ async function register(
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { registerAll } from '@tauri-apps/plugin-global-shortcut';
|
||||
* await registerAll(['CommandOrControl+Shift+C', 'Ctrl+Alt+F12'], (shortcut) => {
|
||||
* console.log(`Shortcut ${shortcut} triggered`);
|
||||
* await registerAll(['CommandOrControl+Shift+C', 'Ctrl+Alt+F12'], (event) => {
|
||||
* console.log(`Shortcut ${event.shortcut} ${event.state}`);
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user