pc_remote/input/
keyboard.rs1use super::Key;
2use crate::prelude::*;
3use enigo::{Direction, Enigo, Keyboard as EnigoKeyboard, Settings};
4
5#[derive(Debug, Clone)]
7pub struct Keyboard;
8
9impl Keyboard {
10 pub fn press(keys: &[Key]) -> Result<()> {
12 let mut enigo = Enigo::new(&Settings::default())?;
13
14 for key in keys {
15 enigo.key(key.clone().into(), Direction::Press)?;
16 }
17
18 Ok(())
19 }
20
21 pub fn release(keys: &[Key]) -> Result<()> {
23 let mut enigo = Enigo::new(&Settings::default())?;
24
25 for key in keys {
26 enigo.key(key.clone().into(), Direction::Release)?;
27 }
28
29 Ok(())
30 }
31}