Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Has a bug User macOS #19

Open
lnd1992 opened this issue Sep 28, 2022 · 5 comments
Open

Has a bug User macOS #19

lnd1992 opened this issue Sep 28, 2022 · 5 comments

Comments

@lnd1992
Copy link

lnd1992 commented Sep 28, 2022

import 'package:flutter/material.dart';
import 'package:hotkey_manager/hotkey_manager.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await hotKeyManager.unregisterAll();

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();

    registerHotkey();
  }

  void registerHotkey() async {
    HotKey hotKey = HotKey(
      KeyCode.keyG,
      modifiers: [
        KeyModifier.meta,
      ],
      scope: HotKeyScope.inapp,
    );
    await hotKeyManager.register(
      hotKey,
      keyDownHandler: (hotKey) {
        print('onKeyDown+${hotKey.toJson()}');
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        color: const Color(0xFFDBDDE0).withOpacity(0.21),
        alignment: Alignment.center,
        child: const TextField(
          decoration: InputDecoration(hintText: 'search'),
        ),
      ),
    );
  }
}
@lnd1992
Copy link
Author

lnd1992 commented Sep 28, 2022

When the registration shortcut key, click common + G, you can print the log, and then click the input box to make it enter the editable state, click common can print the log

当注册快捷键之后,点击common+G,可以打印日志,再点击输入框使其进入可编辑状态,点击common就可以打印日志了

@lnd1992
Copy link
Author

lnd1992 commented Sep 29, 2022

我临时加了在下边两处加了 if (value.character == null) return;来解决这个问题

截屏2022-09-29 10 23 55
截屏2022-09-29 10 24 31

@romannep
Copy link

romannep commented Oct 7, 2022

Looks like I have the same issue: hotkey with meta key fires on just meta key (command key in macOS)
Tested on combination: Enter+Meta

  • first time fires only on full combination
  • after it every Meta press (Command) fires event.
    Reproduces only Meta key. Does not reproduces on Enter+Alt (option) for example

@chenhaoaixuexi
Copy link

+1

@codaveto
Copy link

codaveto commented Aug 22, 2023

me too, triggers on regular cmd. workaround is unregister and register with each keypress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants