Simulate Key (Rust Package)
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
Features
- Simple API: Simulate key combinations with string-based input
- Comprehensive Key Support: Function keys (F1-F24), navigation, numpad, media keys, and more
- Modifier Support: Ctrl, Shift, Alt, Meta/Win/Cmd combinations
- Key Hold: Hold keys for specified durations
- Cross-platform: Works on Windows, macOS, and Linux via
enigo
Installation
Add this to your Cargo.toml:
[]
= "0.1.1"
Usage
use simulate_key;
Supported Keys
Modifiers
ctrl,controlshiftaltmeta,win,cmd,command
Function Keys
f1throughf24
Navigation
home,endpageup,pgup,pagedown,pgdnleft,right,up,downinsert,ins,delete,del
Special Keys
enter,returntab,space,backspaceescape,esccapslock,numlock,scrolllockprintscreen,prtsc,pause
Numpad
numpad0throughnumpad9numpadenter,numpadplus,numpadminusnumpadmultiply,numpaddivide,numpaddot
Media Keys
volumeup,volumedown,volumemutemediaplay,mediastop,medianext,mediaprev
Single Characters
Any single character (letters, numbers, symbols)
Error Handling
The library returns ParseKeyError for invalid key combinations:
match simulate_key