From bbdc3dbfef9fa030fcba8d026599e102668d2367 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 27 Jul 2021 12:54:39 +0700 Subject: Introduce `COMMAND` constant to `keyboard::Modifiers` --- core/src/keyboard/modifiers.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'core') diff --git a/core/src/keyboard/modifiers.rs b/core/src/keyboard/modifiers.rs index 383b9370..e61f145a 100644 --- a/core/src/keyboard/modifiers.rs +++ b/core/src/keyboard/modifiers.rs @@ -28,6 +28,18 @@ bitflags! { } impl Modifiers { + /// The "command" key. + /// + /// This is normally the main modifier to be used for hotkeys. + /// + /// On macOS, this is equivalent to `Self::LOGO`. + /// Ohterwise, this is equivalent to `Self::CTRL`. + pub const COMMAND: Self = if cfg!(target_os = "macos") { + Self::LOGO + } else { + Self::CTRL + }; + /// Returns true if the [`SHIFT`] key is pressed in the [`Modifiers`]. pub fn shift(self) -> bool { self.contains(Self::SHIFT) -- cgit