mirror of
https://github.com/tauri-apps/global-hotkey.git
synced 2026-01-31 00:45:22 +01:00
docs: update docs
This commit is contained in:
5
.changes/docs.md
Normal file
5
.changes/docs.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"global-hotkey": "patch"
|
||||
---
|
||||
|
||||
Update docs
|
||||
19
README.md
19
README.md
@@ -1,5 +1,16 @@
|
||||
global_hotkey lets you register Global HotKeys for Desktop Applications.
|
||||
|
||||
## Platforms-supported:
|
||||
|
||||
- Windows
|
||||
- macOS
|
||||
- Linux (X11 Only)
|
||||
|
||||
## Platform-specific notes:
|
||||
|
||||
- On Windows a win32 event loop must be running on the thread. It doesn't need to be the main thread but you have to create the global hotkey manager on the same thread as the event loop.
|
||||
- On macOS, an event loop must be running on the main thread so you also need to create the global hotkey manager on the main thread.
|
||||
|
||||
## Example
|
||||
|
||||
```rs
|
||||
@@ -15,10 +26,10 @@ let hotkey = HotKey::new(Some(Modifiers::SHIFT), Code::KeyD);
|
||||
manager.register(hotkey);
|
||||
```
|
||||
|
||||
|
||||
## Processing global hotkey events
|
||||
|
||||
You can also listen for the menu events using `GlobalHotKeyEvent::receiver` to get events for the hotkey pressed events.
|
||||
|
||||
```rs
|
||||
use global_hotkey::GlobalHotKeyEvent;
|
||||
|
||||
@@ -27,12 +38,6 @@ if let Ok(event) = GlobalHotKeyEvent::receiver().try_recv() {
|
||||
}
|
||||
```
|
||||
|
||||
## Platforms-supported:
|
||||
|
||||
- Windows
|
||||
- macOS
|
||||
- Linux (X11 Only)
|
||||
|
||||
## License
|
||||
|
||||
Apache-2.0/MIT
|
||||
|
||||
@@ -27,7 +27,7 @@ fn main() {
|
||||
*control_flow = ControlFlow::Poll;
|
||||
|
||||
if let Ok(event) = global_hotkey_channel.try_recv() {
|
||||
println!("{:?}", event);
|
||||
println!("{event:?}");
|
||||
|
||||
if hotkey2.id() == event.id {
|
||||
hotkeys_manager.unregister(hotkey2).unwrap();
|
||||
|
||||
@@ -27,7 +27,7 @@ fn main() {
|
||||
*control_flow = ControlFlow::Poll;
|
||||
|
||||
if let Ok(event) = global_hotkey_channel.try_recv() {
|
||||
println!("{:?}", event);
|
||||
println!("{event:?}");
|
||||
|
||||
if hotkey2.id() == event.id {
|
||||
hotkeys_manager.unregister(hotkey2).unwrap();
|
||||
|
||||
13
src/lib.rs
13
src/lib.rs
@@ -2,8 +2,21 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#![allow(clippy::uninlined_format_args)]
|
||||
|
||||
//! global_hotkey lets you register Global HotKeys for Desktop Applications.
|
||||
//!
|
||||
//! ## Platforms-supported:
|
||||
//!
|
||||
//! - Windows
|
||||
//! - macOS
|
||||
//! - Linux (X11 Only)
|
||||
//!
|
||||
//! ## Platform-specific notes:
|
||||
//!
|
||||
//! - On Windows a win32 event loop must be running on the thread. It doesn't need to be the main thread but you have to create the global hotkey manager on the same thread as the event loop.
|
||||
//! - On macOS, an event loop must be running on the main thread so you also need to create the global hotkey manager on the main thread.
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! ```no_run
|
||||
|
||||
Reference in New Issue
Block a user