shortcuts property

Map<ShortcutActivator, Intent>? shortcuts
final

The default map of keyboard shortcuts to intents for the application.

By default, this is set to WidgetsApp.defaultShortcuts.

Passing this will not replace DefaultTextEditingShortcuts. These can be overridden by using a Shortcuts widget lower in the widget tree. {@tool snippet} This example shows how to add a single shortcut for LogicalKeyboardKey.select to the default shortcuts without needing to add your own Shortcuts widget.

Alternatively, you could insert a Shortcuts widget with just the mapping you want to add between the WidgetsApp and its child and get the same effect.

Widget build(BuildContext context) {
  return WidgetsApp(
    shortcuts: <ShortcutActivator, Intent>{
      ... WidgetsApp.defaultShortcuts,
      const SingleActivator(LogicalKeyboardKey.select): const ActivateIntent(),
    },
    color: const Color(0xFFFF0000),
    builder: (BuildContext context, Widget? child) {
      return const Placeholder();
    },
  );
}

{@end-tool} See also:

  • SingleActivator, which defines shortcut key combination of a single key and modifiers, such as "Delete" or "Control+C".
  • The Shortcuts widget, which defines a keyboard mapping.
  • The Actions widget, which defines the mapping from intent to action.
  • The Intent and Action classes, which allow definition of new actions.

Implementation

final Map<ShortcutActivator, Intent>? shortcuts;