hid_listener 2.0.0 copy "hid_listener: ^2.0.0" to clipboard
hid_listener: ^2.0.0 copied to clipboard

A hid listening library for cross platform listening to keyboard/mouse events.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hid_listener/hid_listener.dart';

void listener(RawKeyEvent event) {
  print(
      "${event is RawKeyDownEvent} ${event.logicalKey.debugName} ${event.isShiftPressed} ${event.isAltPressed} ${event.isControlPressed}");
}

void mouseListener(MouseEvent event) {
  print("${event}");
}

var registerResult = "";

void main() {
  if (!getListenerBackend()!.initialize()) {
    print("Failed to initialize listener backend");
  }

  getListenerBackend()!.addKeyboardListener(listener);
  getListenerBackend()!.addMouseListener(mouseListener);

  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text(registerResult),
        ),
      ),
    );
  }
}
12
likes
140
points
219
downloads

Publisher

unverified uploader

Weekly Downloads

A hid listening library for cross platform listening to keyboard/mouse events.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

ffi, flutter, plugin_platform_interface

More

Packages that depend on hid_listener