isPlatformCommandKeyPressed function
Returns true if any "command" key is pressed on a physical keyboard.
A command key is the "Command" (⌘) key on MacOS, and the "Control" (⌃) key on other platforms.
Implementation
bool isPlatformCommandKeyPressed([TargetPlatform? platform]) {
platform ??= defaultTargetPlatform;
final Set<LogicalKeyboardKey> keys = RawKeyboard.instance.keysPressed;
switch (platform) {
case TargetPlatform.macOS:
return keys.contains(LogicalKeyboardKey.metaLeft) ||
keys.contains(LogicalKeyboardKey.metaRight);
default:
return keys.contains(LogicalKeyboardKey.controlLeft) ||
keys.contains(LogicalKeyboardKey.controlRight);
}
}