Appearance
Function: press()
ts
function press(
ctx: Context,
keys: KeyInput[],
options?: PressKeyOptions): Promise<void>;Defined in: src/keyboard/index.ts:44
Simulate pressing a key or a combination of keys.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | Context | Context object. |
keys | KeyInput[] | Key to press, such as ArrowLeft. See KeyInput for all key names. |
options? | PressKeyOptions | Press behavior: pressDuration, timeBetweenPresses, times, text. |
Returns
Promise<void>
Examples
ts
// Select all text in a text editor
await press(ctx, ['a', 'Control']);ts
// Press Tab to move focus to the next form field
await press(ctx, ['Tab']);ts
// Delete five characters with a short delay between each
await press(ctx, ['Backspace'], { timeBetweenPresses: 100, times: 5, pressDuration: 200 });