inputkit 0.1.0

Keyboard and mouse input automation for Windows
Documentation
//! Keyboard detection and control.

use crate::{Key, platform};

/// Returns `true` once when `key` changes from up to down.
pub fn pressed(key: Key) -> bool {
    platform::key_pressed(key)
}

/// Returns `true` while `key` is held down.
pub fn down(key: Key) -> bool {
    platform::key_down(key)
}

/// Returns `true` once when `key` changes from down to up.
pub fn released(key: Key) -> bool {
    platform::key_released(key)
}

/// Holds `key` down.
/// Returns whether Windows accepted the input.
pub fn press(key: Key) -> bool {
    platform::send_key(key, false)
}

/// Releases `key`.
/// Returns whether Windows accepted the input.
pub fn release(key: Key) -> bool {
    platform::send_key(key, true)
}

/// Presses and releases `key`.
/// Returns whether Windows accepted both input events.
pub fn tap(key: Key) -> bool {
    platform::tap_key(key)
}

/// Types arbitrary Unicode text into the focused application.
/// Returns whether Windows accepted every generated input event.
pub fn type_text(text: &str) -> bool {
    platform::type_text(text)
}