Skip to main content

browser_commander/puppeteer/api/
keyboard.rs

1// @generated by scripts/generate-puppeteer-bindings.mjs from
2// rust/protocol/puppeteer/api.json. Do not edit by hand.
3
4#![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    /// Puppeteer's `Keyboard` (puppeteer-core 25.10.0), a remote object
13    /// served by `browser-commander serve --stdio`.
14    Keyboard
15);
16
17impl Keyboard {
18    /// `Keyboard.down`
19    ///
20    /// ```text
21    /// down(key: KeyInput, options?: Readonly<KeyDownOptions>): Promise<void>
22    /// ```
23    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    /// `Keyboard.up`
28    ///
29    /// ```text
30    /// up(key: KeyInput): Promise<void>
31    /// ```
32    pub async fn up(&self, key: &str) -> Result<(), BridgeError> {
33        self.remote.call("up", vec![Some(Value::from(key))]).await
34    }
35
36    /// `Keyboard.sendCharacter`
37    ///
38    /// ```text
39    /// sendCharacter(char: string): Promise<void>
40    /// ```
41    pub async fn send_character(&self, char: &str) -> Result<(), BridgeError> {
42        self.remote.call("sendCharacter", vec![Some(Value::from(char))]).await
43    }
44
45    /// `Keyboard.type`
46    ///
47    /// ```text
48    /// type(text: string, options?: Readonly<KeyboardTypeOptions>): Promise<void>
49    /// ```
50    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    /// `Keyboard.press`
55    ///
56    /// ```text
57    /// press(key: KeyInput, options?: Readonly<KeyPressOptions>): Promise<void>
58    /// ```
59    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}