windows-key-listener

Crates.iowindows-key-listener
lib.rswindows-key-listener
version0.2.0
created_at2024-09-16 22:13:36.19614+00
updated_at2025-03-16 18:47:35.029502+00
descriptionListen to arbitrary key chords on Windows.
homepage
repositoryhttps://github.com/zmconnelly/windows-key-listener
max_upload_size
id1376940
size37,462
Zach Connelly (zmconnelly)

documentation

README

Windows Key Listener

A Rust library for global keyboard event listening and hotkey management on Windows.

Usage

use windows_key_listener::KeyListener;
use std::{sync::Arc, time::Duration};

fn main() {
    let listener = KeyListener::new();

    // Register shortcuts
    key_listener.listen(
        "Ctrl + Shift + A", 
        Duration::from_millis(200),
        Arc::new(|| {
            on_key_pressed();
            false   // Return true to block the event
        })
    );

    run_your_app();
    
    // When finished, clean up
    key_listener.unlisten();
}

Installation

Add this to your Cargo.toml:

[dependencies]
windows-key-listener = "x.y.z"

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Commit count: 9

cargo fmt