feat: add keyboard shortcuts for notes, the note list and the app
This commit is contained in:
parent
ed2de5e67f
commit
722390ecec
9 changed files with 532 additions and 60 deletions
16
lib/shortcuts.dart
Normal file
16
lib/shortcuts.dart
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import 'dart:ui';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// [key] with Cmd on Apple platforms and Ctrl elsewhere.
|
||||
SingleActivator primaryShortcut(LogicalKeyboardKey key, {bool shift = false}) {
|
||||
final apple = defaultTargetPlatform == TargetPlatform.macOS ||
|
||||
defaultTargetPlatform == TargetPlatform.iOS;
|
||||
return SingleActivator(key, control: !apple, meta: apple, shift: shift);
|
||||
}
|
||||
|
||||
final quitShortcut = primaryShortcut(LogicalKeyboardKey.keyQ);
|
||||
|
||||
Future<void> quitApp() =>
|
||||
ServicesBinding.instance.exitApplication(AppExitType.required);
|
||||
Loading…
Add table
Add a link
Reference in a new issue