Version:
classextends TypedEventEmitter<KeyboardInputEvents, this>

KeyboardClass

KeyboardClass class provides methods to emulate keyboard input

typescript
class KeyboardClass extends TypedEventEmitter<KeyboardInputEvents, this>

Properties

NameTypeDescription
configKeyboardConfigConfig object for KeyboardClass class(default: ...)

Methods

pressKey

pressKey(keys: Key[]): Promise<KeyboardClass>

pressKey presses a single Key or Key combinations
Modifier Keys are to be given in "natural" ordering, so first modifier Keys, followed by the Key to press
**ATTENTION**: There's a difference how regular keys are handled vs. modifier keys.
Modifier keys will be held until released via releaseKey is called.
This means that a modifier key is applied to all subsequent regular key inputs until it is released.
Regular keys, on the other hand, are not held until released, so there's no automatic key repeat.
If you want to have something like key repeat, please use setInterval instead.

Parameters

keysKey[]Array of Keys to press and hold

Returns

Promise<KeyboardClass>

releaseKey

releaseKey(keys: Key[]): Promise<KeyboardClass>

pressKey releases a single Key or Key combinations
Modifier Keys are to be given in "natural" ordering, so first modifier Keys, followed by the Key to release
**ATTENTION**: There's a difference how regular keys are handled vs. modifier keys.
Modifier keys will be held until released via releaseKey is called.
This means that, in contrast to regular keys, a modifier key has to be explicitly released

Parameters

keysKey[]Array of Keys to release

Returns

Promise<KeyboardClass>

type

type(input: StringOrKey): Promise<KeyboardClass>

type types a sequence of String or single Keys via system keyboard

Parameters

inputStringOrKeySequence of String or Key to type

Returns

Promise<KeyboardClass>

Was this page helpful?