Skip to content

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

ParameterTypeDescription
ctxContextContext object.
keysKeyInput[]Key to press, such as ArrowLeft. See KeyInput for all key names.
options?PressKeyOptionsPress 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 });

Matterway Assistant SDK Documentation