Search the site
APP
Give common actions a keyboard shortcut with DVShortcutScope.
Press ? outside a text field to see the shortcuts available here.
ON THIS PAGE
Add shortcuts to a page
Keep typing safe
See the available shortcuts
Save shortcut settings
DVShortcutScope({
'mod+k': openSearch,
'alt+n': newNote,
}, child: pageContent);Copy code to clipboard
Import your generated dartvel_client/dartvel_client.dart barrel. Wrap the page content for page scope, or put the scope in your shared layout for app scope. In an existing Flutter app, MaterialApp.builder can wrap its child. The most deeply focused scope handles a matching shortcut first; leaving that scope removes its shortcuts.
mod means Cmd on macOS and iOS, and Ctrl on other platforms, including the web platform being used.
Use ctrl, cmd (or meta), alt and shift joined with +. Letter keys are case-insensitive; add shift explicitly.
Keys include a–z, 0–9, enter, escape, space, tab, backspace, delete, home, end, pageup, pagedown, up, down, left, right, slash, comma, period, minus, equal and f1–f12.
Unknown keys and duplicate combinations in one scope report an error. A page may intentionally override an app shortcut.
The operating system or browser may reserve a combination before the app receives it. These shortcuts run while the app has focus.
Shortcuts and the ? sheet stay out of a focused text field by default. Set allowInTextFields: true only for a command that should run while editing, such as sending a message with Ctrl+Enter. Text fields can still handle their own built-in editing keys first.
DVShortcutScope.commands(
const [
DVShortcut(
keys: 'mod+k',
command: 'search',
label: 'Search everything',
),
DVShortcut(
keys: 'ctrl+enter',
command: 'send',
label: 'Send message',
allowInTextFields: true,
),
],
actions: {'search': openSearch, 'send': sendMessage},
child: pageContent,
);Copy code to clipboard
Press ? to open the keyboard shortcut sheet. It combines the current scope with its parent scopes and shows a page override once. Use command labels for readable action names; the compact map form uses the key combination as its label. Escape, Back, the Close button or a tap outside closes the sheet.
The ? combination is reserved while showHelp is true. Set showHelp: false if your scope needs to bind that combination itself.
DVShortcut.toJson() and DVShortcut.fromJson() keep settings as data. An editor such as Studio can write this format later. This release provides the format and code API; it does not add a Studio shortcut editor. Each command names an action in the app’s explicit actions map. Loading settings never runs code.
{
"keys": "mod+k",
"command": "search",
"label": "Search everything",
"allowInTextFields": false
}Copy code to clipboard
Store a list of these objects for a scope. Invalid fields, empty command names, missing action callbacks and conflicting combinations are rejected. Keep saved command names stable when renaming labels.
System-wide shortcuts
DV.Platform.shortcuts and the existing DVShortcuts service register native system-wide shortcuts. DVShortcutScope is the widget for keys inside your app.
FSL-1.1-MIT licensed. Built with Dartvel.
Dartvel is made by
To the bottom