pub struct Keystroke {
pub modifiers: Modifiers,
pub key: Key,
}Expand description
One key with its modifiers.
Fields§
§modifiers: ModifiersModifiers held.
key: KeyThe key.
Implementations§
Source§impl Keystroke
impl Keystroke
Sourcepub fn parse(text: &str, os: Os) -> Result<Keystroke, KeystrokeError>
pub fn parse(text: &str, os: Os) -> Result<Keystroke, KeystrokeError>
Parses text: modifiers and a key joined by + ("mod+shift+k",
"mod+-" for Command and minus), in any case (lowercase is the
style; a capital letter is the same key, not Shift). Modifiers:
ctrl, alt (option), shift, cmd (super, win) and mod,
which is Command on Apple platforms (os, apple_keys) and
Control elsewhere. Keys: a character of the US layout typed without Shift (k, 1,
/, [, =: the plus key is =, shift+= with Shift), space,
enter, escape, tab, backspace, delete, the arrows up /
down / left / right, home, end, pageup, pagedown, f1
to f24.
Sourcepub fn parse_with(text: &str, apple: bool) -> Result<Keystroke, KeystrokeError>
pub fn parse_with(text: &str, apple: bool) -> Result<Keystroke, KeystrokeError>
Parses text as Keystroke::parse does, with Apple’s conventions
(mod is Command) or not: a browser decides by the platform it runs
on (apple_keys).
Sourcepub fn reserved(&self, os: Os) -> Option<&'static str>
pub fn reserved(&self, os: Os) -> Option<&'static str>
Why the platform keeps this keystroke for itself on os (quitting,
hiding, minimizing the app or making it full screen), if it does:
such keystrokes cannot be bound.
Sourcepub fn reloads(&self, os: Os) -> bool
pub fn reloads(&self, os: Os) -> bool
Whether this is the development hosts’ reload key on os (mod+r:
Cmd+R, Ctrl+R): built with their dev feature, platforms leave it
to the dev server client, whatever the app binds.
Sourcepub fn edits_text(&self) -> bool
pub fn edits_text(&self) -> bool
Whether a text input that has the keyboard focus uses this
keystroke itself: keys that type, move the caret or delete, and the
editing shortcuts (select all, cut, copy, paste, undo, redo).
Bindings of these keystrokes do not fire while text is edited,
unless they ask to (When::Always).
Source§impl Keystroke
impl Keystroke
Sourcepub fn pressed(self, ctrl_for_command: bool) -> Keystroke
pub fn pressed(self, ctrl_for_command: bool) -> Keystroke
The keys pressed for this keystroke: where Ctrl stands in for
Command (ctrl_for_command, a terminal on macOS that cannot report
Command: crate::platform::Environment::ctrl_for_command), its
Command is Ctrl, so a label shows the key to press (⌃O for
mod+o). A keystroke with both keeps them.