keypress_simulator 0.1.0 copy "keypress_simulator: ^0.1.0" to clipboard
keypress_simulator: ^0.1.0 copied to clipboard

PlatformmacOSWindows
outdated

This plugin allows Flutter desktop apps to simulate key presses.

keypress_simulator #

pub version

This plugin allows Flutter desktop apps to simulate key presses.


English | 简体中文


Platform Support #

Linux macOS Windows
✔️ ✔️

Quick Start #

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  keypress_simulator: ^0.1.0

Or

dependencies:
  keypress_simulator:
    git:
      url: https://github.com/leanflutter/keypress_simulator.git
      ref: main

Usage #

import 'package:keypress_simulator/keypress_simulator.dart';

// 1. Simulate pressing ⌘ + C

// 1.1 Simulate key down
await keyPressSimulator.simulateKeyPress(
  key: LogicalKeyboardKey.keyC,
  modifiers: [ModifierKey.metaModifier],
);

// 1.2 Simulate key up
await keyPressSimulator.simulateKeyPress(
  key: LogicalKeyboardKey.keyC,
  modifiers: [ModifierKey.metaModifier],
  keyDown: false,
);

// 2. Simulate long pressing ⌘ + space

// 2.1. Simulate key down
await keyPressSimulator.simulateKeyPress(
  key: LogicalKeyboardKey.space,
  modifiers: [
    ModifierKey.metaModifier,
  ],
);

await Future.delayed(const Duration(seconds: 5));
                
// 2.2. Simulate key up
await keyPressSimulator.simulateKeyPress(
  key: LogicalKeyboardKey.space,
  modifiers: [
    ModifierKey.metaModifier,
  ],
  keyDown: false,
);

Please see the example app of this plugin for a full example.

Who's using it? #

License #

MIT

16
likes
140
pub points
74%
popularity

Publisher

verified publisherleanflutter.dev

This plugin allows Flutter desktop apps to simulate key presses.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on keypress_simulator