Create jump and macos_command methods in keyboard::Modifiers
This commit is contained in:
parent
8cfa8149f5
commit
3312dc8080
3 changed files with 32 additions and 70 deletions
|
|
@ -84,4 +84,28 @@ impl Modifiers {
|
|||
|
||||
is_pressed
|
||||
}
|
||||
|
||||
/// Returns true if the "jump key" is pressed in the [`Modifiers`].
|
||||
///
|
||||
/// The "jump key" is the modifier key used to widen text motions. It is the `Alt`
|
||||
/// key in macOS and the `Ctrl` key in other platforms.
|
||||
pub fn jump(self) -> bool {
|
||||
if cfg!(target_os = "macos") {
|
||||
self.alt()
|
||||
} else {
|
||||
self.control()
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the "command key" is pressed on a macOS device.
|
||||
///
|
||||
/// This is relevant for macOS-specific actions (e.g. `⌘ + ArrowLeft` moves the cursor
|
||||
/// to the beginning of the line).
|
||||
pub fn macos_command(self) -> bool {
|
||||
if cfg!(target_os = "macos") {
|
||||
self.logo()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue