Skip to main content

Crate keyflow

Crate keyflow 

Source
Expand description

§Keyflow - Cross-Platform Input Simulation

Simulate keyboard and mouse input on Linux (evdev) and Windows (SendInput) with optional global hotkey support.

§Quick Start

use keyflow::prelude::*;

Keyflow::initialize()?;

Keyflow::press_key(Key::A);
Keyflow::click_button(Button::Left);
Keyflow::move_to(500, 300);

§Features

  • Keyboard simulation - Press, release, and click keys
  • Mouse simulation - Move, click, and scroll
  • Global hotkeys - Optional hotkey registration (opt-in via builder)
  • Batch processing - Send multiple events efficiently
  • Multi-monitor - Full multi-monitor coordinate support

§Linux Permissions

Add your user to the input group:

sudo usermod -aG input $USER

Then log out and back in, or run with sudo.

§Hotkeys

use keyflow::prelude::*;

Keyflow::builder()
    .with_hotkeys()  // Enable hotkey support
    .initialize()?;

Keyflow::register_hotkey(
    "save",
    Hotkey::new(Key::S).with_ctrl(),
    || println!("Ctrl+S pressed!")
)?;

§Examples

See the examples directory:

  • basic.rs - Keyboard and mouse basics
  • hotkeys.rs - Global hotkey registration
  • batch.rs - Batch event processing
  • multi_monitor.rs - Multi-monitor positioning
  • serde_config.rs - Save/load automation scripts (requires serde feature)

Modules§

prelude
Commonly used imports

Structs§

ButtonIter
An iterator over the variants of Button
Hotkey
Hotkey combination
KeyIter
An iterator over the variants of Key
Keyflow
Main interface for Keyflow input simulation
KeyflowBuilder
KeyflowBuilder configures the API
Screen
Define the Screen limits

Enums§

Action
Input event action
Button
Mouse button representation
InputEvent
Input event types
Key
Key representation
KeyflowError
Movement
Mouse movement type
Scroll
Mouse scroll

Type Aliases§

Result