Skip to content

3. Keyboard

ROG edited this page Jul 25, 2022 · 2 revisions

Keyboard

Use Keyboard to simulate keystrokes.

class Keyboard

Examples

This example shows a key being pressed.

Keyboard keyboard = Keyboard();
keyboard.press(KeyboardKey.ENTER);

This example shows a key being pressed multiple times until the Duration runs out.

Keyboard keyboard = Keyboard();
await keyboard.pressAndHold(KeyboardKey.A, const Duration(milliseconds: 30));

This example shows a key being pressed a determinated times.

Keyboard keyboard = Keyboard();
keyboard.pressTimes(KeyboardKey.G, 2);

Remarks

See also: KeyboardKey

Constructors

Keyboard({this.enabled = true});

Properties

Name Description
enabled Enable/Disable the keyboard to accept inputs.

Methods

Name Description
void press(KeyboardKey keyInput) Simualte a keystroke.
void pressTimes(KeyboardKey keyInput, int pressTimes) Simulate a keystroke a few times.
Future pressAndHold(KeyboardKey keyInput, Duration duration) async Simualte a keystroke and hold the key until the duration ends.
Clone this wiki locally