Version:
classextends TypedEventEmitter<KeyboardInputEvents, this>

KeyboardClass

class provides methods to emulate keyboard input

typescript
class KeyboardClass extends TypedEventEmitter<KeyboardInputEvents, this>

Properties

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

Methods

pressKey

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

presses a single or combinations
Modifier s are to be given in "natural" ordering, so first modifier s, followed by the to press
**ATTENTION**: There's a difference how regular keys are handled vs. modifier keys.
Modifier keys will be held until released via 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 instead.

Parameters

keysKey[]Array of s to press and hold

Returns

Promise<KeyboardClass>

releaseKey

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

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

Parameters

keysKey[]Array of s to release

Returns

Promise<KeyboardClass>

type

type(input: StringOrKey): Promise<KeyboardClass>

types a sequence of or single s via system keyboard

Parameters

inputStringOrKeySequence of or to type

Returns

Promise<KeyboardClass>

Was this page helpful?