Introduce COMMAND constant to keyboard::Modifiers

This commit is contained in:
Héctor Ramón Jiménez 2021-07-27 12:54:39 +07:00
parent 1cef6a2a58
commit bbdc3dbfef
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -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)