#keyboard-events #key #windows #key-events #chord #hotkey #event-listener

windows-key-listener

Listen to arbitrary key chords on Windows

3 releases

0.1.3 Sep 16, 2024
0.1.2 Sep 16, 2024
0.1.1 Sep 16, 2024

#288 in Concurrency

MIT license

15KB
256 lines

Rust Key Listener

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

Features

  • Global keyboard event capture
  • Support for complex key chord combinations
  • Customizable callback execution on key events
  • Configurable event blocking and trigger intervals
  • Thread-safe design for concurrent operations

Usage

use std::time::Duration;
use std::sync::Arc;

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

    listener.listen(
        "Ctrl+Shift+A",
        true,
        Duration::from_millis(500),
        Arc::new(|| println!("Hotkey triggered!"))
    );

    // Keep the main thread alive
    std::thread::park();
}

Installation

Add this to your Cargo.toml:

[dependencies]
key_listener = "0.1.3"

Requirements

  • Windows OS
  • Rust 1.80+

License

MIT License

Contributing

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

Dependencies

~127MB
~2M SLoC