browser_commander/puppeteer/api/
keyboard.rs1#![allow(clippy::all, missing_docs, unused_imports, non_snake_case)]
5
6use serde_json::Value;
7
8use super::*;
9use crate::puppeteer::bridge::{binary, remote_type, BridgeError, JsFunction, Remote};
10
11remote_type!(
12 Keyboard
15);
16
17impl Keyboard {
18 pub async fn down(&self, key: &str, options: Option<Value>) -> Result<(), BridgeError> {
24 self.remote.call("down", vec![Some(Value::from(key)), options]).await
25 }
26
27 pub async fn up(&self, key: &str) -> Result<(), BridgeError> {
33 self.remote.call("up", vec![Some(Value::from(key))]).await
34 }
35
36 pub async fn send_character(&self, char: &str) -> Result<(), BridgeError> {
42 self.remote.call("sendCharacter", vec![Some(Value::from(char))]).await
43 }
44
45 pub async fn r#type(&self, text: &str, options: Option<Value>) -> Result<(), BridgeError> {
51 self.remote.call("type", vec![Some(Value::from(text)), options]).await
52 }
53
54 pub async fn press(&self, key: &str, options: Option<Value>) -> Result<(), BridgeError> {
60 self.remote.call("press", vec![Some(Value::from(key)), options]).await
61 }
62}