pub trait KeyboardControllable {
    // Required methods
    fn key_sequence(&mut self, sequence: &str);
    fn key_down(&mut self, key: Key);
    fn key_up(&mut self, key: Key);
    fn key_click(&mut self, key: Key);

    // Provided methods
    fn key_sequence_parse(&mut self, sequence: &str)
       where Self: Sized { ... }
    fn key_sequence_parse_try(
        &mut self,
        sequence: &str
    ) -> Result<(), ParseError>
       where Self: Sized { ... }
}
Expand description

Contains functions to simulate key presses and to input text.

For the keyboard there are currently two modes you can use. The first mode is represented by the key_sequence function. It’s purpose is to simply write unicode characters. This is independent of the keyboard layout. Please note that you’re not be able to use modifier keys like Control to influence the outcome. If you want to use modifier keys to e.g. copy/paste, use the Layout variant. Please note that this is indeed layout dependent.

Required Methods§

source

fn key_sequence(&mut self, sequence: &str)

Enter the text. You can use unicode here like: ❤️. This works regardless of the current keyboardlayout. You cannot use this function for entering shortcuts or something similar. For shortcuts, use the KeyboardControllable::key_click method instead.

Example
use enigo::*;
let mut enigo = Enigo::new();
enigo.key_sequence("hello world ❤️");
source

fn key_down(&mut self, key: Key)

Press down the given key

source

fn key_up(&mut self, key: Key)

Release a pressed down key

source

fn key_click(&mut self, key: Key)

Press and release the key. It is the same as calling the KeyboardControllable::key_down and KeyboardControllable::key_up functions consecutively

Provided Methods§

source

fn key_sequence_parse(&mut self, sequence: &str)where Self: Sized,

Type the string parsed with DSL.

Typing {+SHIFT}hello{-SHIFT} becomes HELLO. Please have a look at the dsl module for more information.

source

fn key_sequence_parse_try(&mut self, sequence: &str) -> Result<(), ParseError>where Self: Sized,

Same as KeyboardControllable::key_sequence_parse except returns any errors

Errors

Returns a dsl::ParseError if the sequence cannot be parsed

Implementors§