Skip to main content

freya_core/events/
modifiers.rs

1use keyboard_types::Modifiers;
2
3/// Extension trait for [`Modifiers`] adding OS-aware helpers.
4pub trait ModifiersExt {
5    /// Returns the platform's command modifier.
6    ///
7    /// Maps to [`Modifiers::META`] (Command) on macOS and to [`Modifiers::CONTROL`]
8    /// on every other platform. Useful to express shortcuts like copy, paste or
9    /// select-all once and have them work natively on every OS.
10    fn ctrl_or_meta() -> Modifiers;
11}
12
13impl ModifiersExt for Modifiers {
14    fn ctrl_or_meta() -> Modifiers {
15        if cfg!(target_os = "macos") {
16            Modifiers::META
17        } else {
18            Modifiers::CONTROL
19        }
20    }
21}