Skip to main content
Page keyboard methods for the Puppeteer driver.

keyboard.down

Dispatches a keydown event.
If key is a single character and no modifier keys besides Shift are being held down, a keypress/input event will also be generated. The text option can be specified to force an input event to be generated.Modifier keys DO affect keyboard.down. Holding down Shift will type the text in upper case.
Upstream docs
key
PuppeteerKeyInput
required
Name of key to press, such as ArrowLeft.
options
PuppeteerKeyDownOptions
Options for the key down event.
await page.keyboard.down(/* PuppeteerKeyInput */);

keyboard.up

Dispatches a keyup event. Upstream docs
key
PuppeteerKeyInput
required
Name of key to release, such as ArrowLeft.
await page.keyboard.up(/* PuppeteerKeyInput */);

keyboard.press

Shortcut for Keyboard.down and Keyboard.up.
If key is a single character and no modifier keys besides Shift are being held down, a keypress/input event will also be generated. The text option can be specified to force an input event to be generated.Modifier keys DO affect keyboard.press. Holding down Shift will type the text in upper case.
Upstream docs
key
PuppeteerKeyInput
required
Name of key to press, such as ArrowLeft.
options
PuppeteerKeyPressOptions
Options for the key press event including delay, text, and commands.
await page.keyboard.press(/* PuppeteerKeyInput */);

keyboard.sendCharacter

Dispatches a keypress and input event. This does not send a keydown or keyup event.
Modifier keys DO NOT affect keyboard.sendCharacter. Holding down Shift will not type the text in upper case.
Upstream docs
char
string
required
Character to send into the page.
await page.keyboard.sendCharacter('...');

keyboard.type

Sends a keydown, keypress/input, and keyup event for each character in the text.
To press a special key, like Control or ArrowDown, use Keyboard.press.Modifier keys DO NOT affect keyboard.type. Holding down Shift will not type the text in upper case.
Upstream docs
text
string
required
A text to type into a focused element.
options
PuppeteerKeyboardTypeOptions
Options for typing including delay between key presses.
await page.keyboard.type('...');