Skip to main content
The Keyboard class provides methods to simulate keyboard input such as typing text and pressing keys. Access the Keyboard instance through page.keyboard.

Methods

type

Types text character by character.
string
required
The text to type
number
Time to wait between key presses in milliseconds. Defaults to 0.

press

Presses a single key or a key combination.
string
required
The key or key combination to press. See key values for valid values.
number
Time to wait between keydown and keyup in milliseconds. Defaults to 0.

down

Holds down a key.
string
required
The key to hold down. See key values for valid values.

up

Releases a key.
string
required
The key to release. See key values for valid values.

insertText

Inserts text without simulating key presses.
string
required
The text to insert
This method dispatches an input event directly, which is much faster than type() but does not trigger keydown, keypress, or keyup events.

Example Usage

Type Text with Delay

Keyboard Shortcuts

Hold Modifier Keys

Press Special Keys