Skip to main content
Press a single key or a keyboard shortcut in the sandbox:
To enter text, use type() instead.

Signature

Parameters

KeyboardKey[]
required
The keys to press, as a shortcut. TestDriver presses them in order, holds them all down, then releases them in reverse order. So ['ctrl', 'shift', 'i'] is Ctrl+Shift+I.Each name must be a valid KeyboardKey. See Key names.
Because the keys are pressed together, ['enter', 'enter'] doesn’t press Enter twice. Call pressKeys() once per key press instead.

Key names

Key names are lowercase. The most common ones: The full list is the KeyboardKey type in sdk.d.ts, which your editor autocompletes.
Sandboxes run Linux by default, or Windows. Use 'ctrl' for shortcuts like copy and paste, not 'command'.

Examples

Move between form fields

Replace the text in a field

Go to a URL in Chrome

Complete example

tests/keyboard-login.test.mjs
  • type(): enter text into the focused field
  • click(): focus a field before you type or press keys
  • Perform actions: every kind of action in one guide