Skip to main content

KeyInjector

Trait KeyInjector 

Source
pub trait KeyInjector: Send {
    // Required methods
    fn type_text(&mut self, text: &str) -> Result<()>;
    fn backspace(&mut self, count: usize) -> Result<()>;
    fn send_combo(&mut self, keys: &[Key]) -> Result<()>;
    fn set_key_delay(&mut self, delay: Duration);
}
Expand description

High-level text-injection abstraction.

This unifies the available keystroke backends behind a single trait so a caller can pick an implementation at runtime (e.g. the layout-independent Wayland [wayland_vk::WaylandVkKeyboard] when the compositor supports zwp_virtual_keyboard_v1, falling back to the uinput Keyboard otherwise) without changing the typing code.

The semantics mirror Keyboard’s inherent methods.

Required Methods§

Source

fn type_text(&mut self, text: &str) -> Result<()>

Type text by injecting the corresponding keystrokes.

Source

fn backspace(&mut self, count: usize) -> Result<()>

Emit Backspace count times.

Source

fn send_combo(&mut self, keys: &[Key]) -> Result<()>

Press all keys in keys, then release them in reverse order.

Source

fn set_key_delay(&mut self, delay: Duration)

Set the inter-event delay used between injected key events.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§