# Keyflow
[](https://crates.io/crates/keyflow)
[](https://docs.rs/keyflow)
Cross-platform input simulation library for Rust. Simulate keyboard and mouse input, and register global hotkeys on Linux and Windows.
### Optional Features
```toml
[dependencies]
keyflow = { version = "0.1", features = ["serde"] }
```
- **`serde`** - Enable serialization/deserialization of input events
## Quick Start
```rust
use keyflow::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize Keyflow
Keyflow::initialize()?;
// Simulate keyboard
Keyflow::press_key(Key::A);
Keyflow::click_key(Key::Enter);
// Simulate mouse
Keyflow::move_to(500, 300);
Keyflow::click_button(Button::Left);
Keyflow::scroll_vertical(-3);
Ok(())
}
```
## Platform Requirements
### Linux
Keyflow requires access to `/dev/uinput` for input simulation. Add your user to the `input` group:
```bash
sudo usermod -aG input $USER
```
Then log out and back in, or run your program with `sudo`.
**Note:** On Linux, the virtual device may take 1-2 seconds to be fully registered after initialization.
### Windows
No special permissions required.
## Examples
Full examples are available in the [`examples/`](examples/) directory:
- **[`basic.rs`](examples/basic.rs)** - Keyboard and mouse basics
- **[`hotkeys.rs`](examples/hotkeys.rs)** - Global hotkey registration
- **[`batch.rs`](examples/batch.rs)** - Batch event processing
- **[`multi_monitor.rs`](examples/multi_monitor.rs)** - Multi-monitor positioning
- **[`serde_config.rs`](examples/serde_config.rs)** - Save/load automation scripts