LogicalKeyboardKey.meta in shortcut is triggered without pressing the other keys in the LogicalKeySet

Keff - Mar 21 '22 - - Dev Community

Originally posted on: https://stackoverflow.com/questions/71556680/logicalkeyboardkey-meta-in-shortcut-is-triggered-without-pressing-the-other-keys

I've been working with Shortcuts, Actions and key binds with Flutter web. And I've found a weird behaviour that I can't find a solution to.

The thing is, I have defined a series of LogicalKeySet for a set of actions. I create 2 per action, one for windows and one for mac. They look something like this:

final boldKeySetWindows = LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyB);
final boldKeySetMac = LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyB);
Enter fullscreen mode Exit fullscreen mode

I add them to the Actions widget as specified here.

final boldKeySetWindows = LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyB);
final boldKeySetMac = LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyB);

Shortcuts(
  shortcuts: {
    boldKeySetWindows: MEFormatIntent(boldFormatter),
    boldKeySetMac: MEFormatIntent(boldFormatter),
  },
  child: Actions(
    dispatcher: MEFormatActionDispatcher(),
    actions: <Type, Action<Intent>>{
      MEFormatIntent: MEFormatAction(_controller),
    },
  )
);
Enter fullscreen mode Exit fullscreen mode

The problem or weird behaviour is the following, for windows (using control) it works fine, it only executes MEFormatAction when both ctrl and b are pressed.

But if I try using the meta key or key plus b it works correctly the first time you press cmd+b, but after that, if I quickly press cmd again, it executes MEFormatAction again. (This behaviour does not happen with ctrl)

Am I missing something, or is this a bug?

I have not tried anything as I have been unsuccessful in finding information regarding this behaviour, any help or advice is highly appreciated!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .