pub struct Keyboard { /* private fields */ }Expand description
High-level helper for dispatching keyboard events through the CDP Input domain.
§Examples
let keyboard = page.keyboard();
keyboard.press_key("Enter").await?;Implementations§
Source§impl Keyboard
impl Keyboard
Sourcepub async fn key_down(&self, input: impl Into<KeyInput>) -> Result<()>
pub async fn key_down(&self, input: impl Into<KeyInput>) -> Result<()>
Dispatches a keyDown event for the provided key input.
Sourcepub async fn key_down_with_modifiers(
&self,
input: impl Into<KeyInput>,
modifiers: KeyModifiers,
) -> Result<()>
pub async fn key_down_with_modifiers( &self, input: impl Into<KeyInput>, modifiers: KeyModifiers, ) -> Result<()>
Dispatches a keyDown event while applying the given modifiers.
Sourcepub async fn key_up(&self, input: impl Into<KeyInput>) -> Result<()>
pub async fn key_up(&self, input: impl Into<KeyInput>) -> Result<()>
Dispatches a matching keyUp event.
Sourcepub async fn key_up_with_modifiers(
&self,
input: impl Into<KeyInput>,
modifiers: KeyModifiers,
) -> Result<()>
pub async fn key_up_with_modifiers( &self, input: impl Into<KeyInput>, modifiers: KeyModifiers, ) -> Result<()>
Dispatches a keyUp event while applying the given modifiers.
Sourcepub async fn press_key(&self, input: impl Into<KeyInput>) -> Result<()>
pub async fn press_key(&self, input: impl Into<KeyInput>) -> Result<()>
Sends a full key press (a keyDown followed by a keyUp).
Sourcepub async fn press_key_with_modifiers(
&self,
input: impl Into<KeyInput>,
modifiers: KeyModifiers,
) -> Result<()>
pub async fn press_key_with_modifiers( &self, input: impl Into<KeyInput>, modifiers: KeyModifiers, ) -> Result<()>
Sends a key press while holding the provided modifiers.
§Examples
let keyboard = page.keyboard();
keyboard
.press_key_with_modifiers("r", KeyModifiers::from_iter([KeyboardModifier::Control]))
.await?;Sourcepub async fn press_character(&self, ch: char) -> Result<()>
pub async fn press_character(&self, ch: char) -> Result<()>
Presses the primary key that corresponds to the given character.
Sourcepub async fn press_with_modifiers(
&self,
key: impl Into<KeyInput>,
modifiers: impl IntoIterator<Item = KeyboardModifier>,
) -> Result<()>
pub async fn press_with_modifiers( &self, key: impl Into<KeyInput>, modifiers: impl IntoIterator<Item = KeyboardModifier>, ) -> Result<()>
Presses modifiers in order, executes the target key once, and releases modifiers in reverse.
§Examples
let keyboard = page.keyboard();
keyboard
.press_with_modifiers("l", [KeyboardModifier::Control, KeyboardModifier::Shift])
.await?;Trait Implementations§
Auto Trait Implementations§
impl Freeze for Keyboard
impl !RefUnwindSafe for Keyboard
impl Send for Keyboard
impl Sync for Keyboard
impl Unpin for Keyboard
impl !UnwindSafe for Keyboard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more