import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; /// Whether [event] opens or closes the design switcher: Alt+L (Option+L on /// a Mac, L for look) with no other modifier, from any destination. Option+L /// types a symbol (¬) on a Mac, so the key is matched by position as well. /// Repeats of a held chord match too, so the caller can swallow them; only /// the first press acts. /// /// The chord sits beside Alt+K (the chat switcher) and works the same way. /// Alt+T (the terminal) and Alt+D (the browser's address bar) are taken, and /// no Ctrl or Cmd chord is free for it: Ctrl+L and Cmd+L are the browser's /// address bar and the terminal's clear screen, Ctrl+Alt+T and Ctrl+Alt+L /// open a terminal and lock the screen on Linux desktops. No browser, /// GNOME, KDE or macOS takes Alt+L. The terminal keeps it for readline /// (downcase-word), so the caller leaves it to the terminal while it has the /// keyboard. bool shellDesignShortcut(KeyEvent event, HardwareKeyboard keyboard) { if (event is KeyUpEvent || !keyboard.isAltPressed || keyboard.isControlPressed || keyboard.isMetaPressed || keyboard.isShiftPressed) { return false; } return event.logicalKey == LogicalKeyboardKey.keyL || event.physicalKey == PhysicalKeyboardKey.keyL; } /// The chord as it reads on [platform], for the help page. String shellDesignShortcutLabel([TargetPlatform? platform]) { final target = platform ?? defaultTargetPlatform; final apple = target == TargetPlatform.macOS || target == TargetPlatform.iOS; return apple ? 'Option+L' : 'Alt+L'; }