pub struct Keyboard<'a> { /* private fields */ }Expand description
A struct for controlling a virtual keyboard.
It holds a reference to a Device which is used to send the keyboard commands.
Implementations§
Source§impl<'a> Keyboard<'a>
impl<'a> Keyboard<'a>
Sourcepub fn press(&self, button: Key)
pub fn press(&self, button: Key)
Presses a single keyboard button.
The button is held down until a release() or multi_press() with Key::NONE is called.
§Arguments
button- TheKeyto press.
Sourcepub fn release(&self)
pub fn release(&self)
Releases all currently pressed keyboard buttons.
This effectively sends a “no keys pressed” command to the device.
Sourcepub fn press_and_release(&self, button: Key, millis: u64)
pub fn press_and_release(&self, button: Key, millis: u64)
Presses and releases a single keyboard button.
The button is pressed down, held for the specified duration, then released.
§Arguments
button- TheKeyto press and release.millis- The duration in milliseconds to hold the button down before releasing it.
Sourcepub fn multi_press(
&self,
button1: Key,
button2: Key,
button3: Key,
button4: Key,
button5: Key,
button6: Key,
)
pub fn multi_press( &self, button1: Key, button2: Key, button3: Key, button4: Key, button5: Key, button6: Key, )
Presses up to six keyboard buttons simultaneously.
This can be used for pressing modifier keys and other keys at the same time.
§Arguments
button1- The firstKeyto press.button2- The secondKeyto press.button3- The thirdKeyto press.button4- The fourthKeyto press.button5- The fifthKeyto press.button6- The sixthKeyto press.
Sourcepub fn type_string(&self, string: &str, millis: u64) -> Result<(), String>
pub fn type_string(&self, string: &str, millis: u64) -> Result<(), String>
Types a string by simulating individual key presses for each character.
§Arguments
string- The string to be typed.millis- The duration in milliseconds to hold the button down before releasing it.
§Errors
This function will return an error if a character in the input string
cannot be converted into a valid Key enum variant.