Keyboard methods, browser sessions serve 2, phone sessions 2 and computer sessions 2. A method marked not served answers StrategyUnavailable on that kind of session; check the handshake’s capabilities before relying on one.
Keyboard.typeText
Browser: served
Phone: served
Computer: served
Takes targetId
Type text into whatever has focus.
| Param | Type | Required | Description |
|---|---|---|---|
text | string | Yes | |
input | string | No | How the input reaches the page. Browsers serve os (the default), real operating system input; simulated answers StrategyUnavailable. |
delayMs | integer | No | The pause between keys, as Playwright’s pressSequentially delay. Omitted or 0 types at the default pace. From 0 to 1000. |
idempotencyKey | string | No | Makes a re-send after a reconnect safe: a repeated key returns the recorded response without acting again. See Idempotency keys. |
{}.
Keyboard.keyPress
Browser: served
Phone: served
Computer: served
Takes targetId
Press and release one key on whatever has focus, holding any modifiers for the press. key is a named key or a single printable character (for chords such as ctrl+a). Text is sent with Keyboard.typeText, not as key presses.
| Param | Type | Required | Description |
|---|---|---|---|
key | string | Yes | A named key, or a single printable character. Playwright’s spellings of named keys (“Enter”, “ArrowDown”, “PageUp”) are accepted too. |
modifiers | string[] | No | Modifier keys to hold. A session that cannot hold modifiers answers StrategyUnavailable. One of ctrl, shift, alt, meta. |
input | string | No | How the input reaches the page. Browsers serve os (the default), real operating system input; simulated answers StrategyUnavailable. |
idempotencyKey | string | No | Makes a re-send after a reconnect safe: a repeated key returns the recorded response without acting again. See Idempotency keys. |
{}.