KeyboardClass class constructor
Config object for KeyboardClass class
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.
// Will press and hold key combination CTRL + V
await keyboard.pressKey(Key.LeftControl, Key.V);
// This will press and hold the Shift key, so the Shift modifier is applied to each subsequent key input
await keyboard.pressKey(Key.LeftShift);
await keyboard.pressKey(Key.H);
await keyboard.pressKey(Key.E);
await keyboard.pressKey(Key.L);
await keyboard.pressKey(Key.L);
await keyboard.pressKey(Key.O);
await keyboard.releaseKey(Key.LeftShift);
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
// Will press and hold key combination CTRL + V
await keyboard.pressKey(Key.LeftControl, Key.V);
// To release the key combination CTRL + V, it's actually sufficient to call releaseKey on the modifier key
await keyboard.releaseKey(Key.LeftControl);
Rest
...input: StringOrKeySequence of String or Key to type
await keyboard.type(Key.A, Key.S, Key.D, Key.F);
await keyboard.type("Hello, world!");
Generated using TypeDoc
KeyboardClass class provides methods to emulate keyboard input