Dartvel, home
Docs
Features
Studio
Cloud
Compared

Search the site

GitHub
pub.dev

GETTING STARTED

Getting started
Existing Flutter apps
Existing Native apps
Run on your phone

APP

UI and styling
Routing
State
Accessibility
Keyboard shortcuts
Localization
Devices and desktop
Native device access
Media, 3D and XR

DATA

Data models
Forms
Search
Sync and offline
Import and export
Change capture
Database
Cache
File storage
Images
Privacy and erasure

BACKEND

Backend functions
Auth and sessions
Authorization
Queues and jobs
Workers and memory
Notifications and mail
Outbound HTTP
AI
Webhooks
GraphQL and OpenAPI
API keys and OAuth
Multi-tenancy
Billing and commerce
Modules

OPERATIONS

Edge security
Secrets and environments
Monitoring
Releases

SHIPPING

Build targets
Telegram Mini Apps
Static web hosting
Servers and deploying

REFERENCE

Testing
CLI reference
Coding agents

APP

Keyboard shortcuts

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

Add shortcuts to a page

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.

Keep typing safe

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

See the available shortcuts

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.

Save shortcut settings

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.

PREVIOUS Accessibility Build-time audit, switch control and remote keys
NEXT Localization Typed translation keys, plurals and ARB files
GitHub
pub.dev
npm
Acknowledgements
Privacy
Terms

FSL-1.1-MIT licensed. Built with Dartvel.

Dartvel is made by

SigmaDev Digital

To the bottom