Skip to main content

CdpKeyboard

Struct CdpKeyboard 

Source
pub struct CdpKeyboard<OT: ConnectionTransport> {
    pub modifiers: Arc<Mutex<i64>>,
    /* private fields */
}

Fields§

§modifiers: Arc<Mutex<i64>>

Modifier bitmask (Alt=1, Ctrl=2, Meta=4, Shift=8) — shared with CdpMouse.

Implementations§

Source§

impl<OT: ConnectionTransport> CdpKeyboard<OT>

Source

pub fn new( session: Arc<TokioMutex<CdpSession<OT>>>, modifiers: Arc<Mutex<i64>>, ) -> Self

Source

pub async fn down(&self, key: &str) -> Result<(), InputError>

Press a key down. Uses the keymap for non-printable keys; falls back gracefully.

Source

pub async fn up(&self, key: &str) -> Result<(), InputError>

Release a key.

Source

pub async fn press(&self, key: &str, delay_ms: u64) -> Result<(), InputError>

Press and release a key (optionally holding for delay_ms between down and up).

Source

pub async fn hold_press( &self, key: &str, hold_for: u64, step_range: DelayRange, ) -> Result<(), InputError>

Hold a key down for hold_for milliseconds, firing autoRepeat keydown events at random intervals sampled from step_range, then release. The first repeat is delayed 3–5× longer than normal to mirror OS initial-repeat latency.

Source

pub async fn send_character(&self, ch: &str) -> Result<(), InputError>

Send a raw character via Input.insertText (bypasses key definitions).

Source

pub async fn type_text( &self, text: &str, delay_ms: u64, ) -> Result<(), InputError>

Type text, using press() for known keys and send_character() for others. delay_ms is inserted between each character.

Trait Implementations§

Source§

impl<OT: Clone + ConnectionTransport> Clone for CdpKeyboard<OT>

Source§

fn clone(&self) -> CdpKeyboard<OT>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<OT: ConnectionTransport> Keyboard for CdpKeyboard<OT>

Source§

async fn down( &self, key: &str, _context: &BrowsingContext, ) -> Result<(), BidiInputError>

Source§

async fn up( &self, key: &str, _context: &BrowsingContext, ) -> Result<(), BidiInputError>

Source§

async fn press( &self, key: &str, _context: &BrowsingContext, options: Option<KeyPressOptions>, ) -> Result<(), BidiInputError>

Source§

async fn type_text( &self, text: &str, _context: &BrowsingContext, options: Option<KeyboardTypeOptions>, ) -> Result<(), BidiInputError>

Auto Trait Implementations§

§

impl<OT> Freeze for CdpKeyboard<OT>

§

impl<OT> !RefUnwindSafe for CdpKeyboard<OT>

§

impl<OT> Send for CdpKeyboard<OT>
where OT: Send,

§

impl<OT> Sync for CdpKeyboard<OT>
where OT: Send,

§

impl<OT> Unpin for CdpKeyboard<OT>

§

impl<OT> UnsafeUnpin for CdpKeyboard<OT>

§

impl<OT> !UnwindSafe for CdpKeyboard<OT>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more