flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
163.72k stars 26.93k forks source link

[Shortcuts] Support prefix keys #132879

Open loic-sharma opened 11 months ago

loic-sharma commented 11 months ago

Is there an existing issue for this?

Use case

Desktop apps often support keyboard shortcuts "chords" with multiple separate keypresses. Examples:

  1. Visual Studio Code: Ctrl+K Ctrl+O opens a folder
  2. Gmail: g i goes to the inbox

Proposal

Add a new ShortcutActivator to support this. Strawman example:

// Activated by Ctrl+K followed by Ctrl+O
const openFolderActivator = ChordActivator(
  activators: <ShortcutActivator>[
    SingleActivator(LogicalKeyboardKey.keyK, control: true),
    SingleActivator(LogicalKeyboardKey.keyO, control: true),
  ],
);

return Shortcuts(
  shortcuts: const <ShortcutActivator, Intent>{
    openFolderActivator: OpenFolderIntent(),
  },
  child: ...,
);
flutter-triage-bot[bot] commented 1 month ago

The triaged-desktop label is irrelevant if there is no team-desktop label or fyi-desktop label.

justinmc commented 1 month ago

@gspencergoog Did you have any thoughts on sequences of keys in Shortcuts when you wrote it?