| Crates.io | simulate_key |
| lib.rs | simulate_key |
| version | 0.1.1 |
| created_at | 2025-06-06 18:13:30.057528+00 |
| updated_at | 2025-06-06 18:26:13.022539+00 |
| description | A simple key combination simulator using enigo |
| homepage | |
| repository | https://github.com/vtempest/simulate_key.rs |
| max_upload_size | |
| id | 1703312 |
| size | 35,617 |
A simple Rust library for simulating keyboard input using the enigo crate. This library provides an easy-to-use interface for sending key combinations programmatically.
cargo add simulate_key
enigoAdd this to your Cargo.toml:
[dependencies]
simulate_key = "0.1.1"
use simulate_key::simulate_key;
fn main() {
// Basic key combinations
simulate_key("ctrl+c").unwrap();
simulate_key("alt+tab").unwrap();
simulate_key("ctrl+shift+t").unwrap();
// Function keys
simulate_key("f5").unwrap();
simulate_key("ctrl+f12").unwrap();
// Navigation
simulate_key("ctrl+home").unwrap();
simulate_key("shift+end").unwrap();
// Single characters
simulate_key("a").unwrap();
simulate_key("enter").unwrap();
// Hold keys
use simulate_key::simulate_key_hold;
simulate_key_hold("space", 500).unwrap(); // Hold space for 500ms
}
ctrl, controlshiftaltmeta, win, cmd, commandf1 through f24home, endpageup, pgup, pagedown, pgdnleft, right, up, downinsert, ins, delete, delenter, returntab, space, backspaceescape, esccapslock, numlock, scrolllockprintscreen, prtsc, pausenumpad0 through numpad9numpadenter, numpadplus, numpadminusnumpadmultiply, numpaddivide, numpaddotvolumeup, volumedown, volumemutemediaplay, mediastop, medianext, mediaprevAny single character (letters, numbers, symbols)
The library returns ParseKeyError for invalid key combinations:
match simulate_key("invalid+key") {
Ok(()) => println!("Key simulated successfully"),
Err(e) => println!("Error: {}", e),
}