pub struct KeyboardShortcut<R: Runtime> { /* private fields */ }
Implementations§
Source§impl<R: Runtime> KeyboardShortcut<R>
impl<R: Runtime> KeyboardShortcut<R>
pub fn new(key: impl AsRef<str>) -> Self
Sourcepub fn builder(key: impl AsRef<str>) -> KeyboardShortcutBuilder<R>
pub fn builder(key: impl AsRef<str>) -> KeyboardShortcutBuilder<R>
Initialize a new keyboard shortcut builder with the specified key.
Sourcepub fn with_modifiers(key: impl AsRef<str>, modifiers: &[ModifierKey]) -> Self
pub fn with_modifiers(key: impl AsRef<str>, modifiers: &[ModifierKey]) -> Self
Create a new keyboard shortcut with the specified key and modifiers.
Sourcepub fn with_alt(key: impl AsRef<str>) -> Self
pub fn with_alt(key: impl AsRef<str>) -> Self
Create a new keyboard shortcut with the specified key and the AltKey
modifier.
§Example
use tauri_plugin_prevent_default::KeyboardShortcut;
use tauri_plugin_prevent_default::ModifierKey::AltKey;
// Both of these are equivalent.
tauri_plugin_prevent_default::Builder::new()
.shortcut(KeyboardShortcut::with_alt("A"))
.shortcut(KeyboardShortcut::with_modifiers("A", &[AltKey]))
.build();
Sourcepub fn with_ctrl(key: impl AsRef<str>) -> Self
pub fn with_ctrl(key: impl AsRef<str>) -> Self
Create a new keyboard shortcut with the specified key and the CtrlKey
modifier.
Sourcepub fn with_ctrl_meta(key: impl AsRef<str>) -> Self
pub fn with_ctrl_meta(key: impl AsRef<str>) -> Self
Create a new keyboard shortcut with the specified key and the CtrlKey
and MetaKey
modifiers.
Sourcepub fn with_ctrl_shift(key: impl AsRef<str>) -> Self
pub fn with_ctrl_shift(key: impl AsRef<str>) -> Self
Create a new keyboard shortcut with the specified key and the CtrlKey
and ShiftKey
modifiers.
Sourcepub fn with_meta(key: impl AsRef<str>) -> Self
pub fn with_meta(key: impl AsRef<str>) -> Self
Create a new keyboard shortcut with the specified key and the MetaKey
modifier.
Sourcepub fn with_shift(key: impl AsRef<str>) -> Self
pub fn with_shift(key: impl AsRef<str>) -> Self
Create a new keyboard shortcut with the specified key and the ShiftKey
modifier.
Sourcepub fn with_shift_alt(key: impl AsRef<str>) -> Self
pub fn with_shift_alt(key: impl AsRef<str>) -> Self
Create a new keyboard shortcut with the specified key and the ShiftKey
and AltKey
modifiers.
Sourcepub fn with_shift_meta(key: impl AsRef<str>) -> Self
pub fn with_shift_meta(key: impl AsRef<str>) -> Self
Create a new keyboard shortcut with the specified key and the ShiftKey
and MetaKey
modifiers.
Sourcepub fn with_listener<F>(key: impl AsRef<str>, listener: F) -> Self
pub fn with_listener<F>(key: impl AsRef<str>, listener: F) -> Self
Create a new keyboard shortcut with the specified key and a listener.
Sourcepub fn modifiers(&self) -> &[ModifierKey]
pub fn modifiers(&self) -> &[ModifierKey]
The modifiers of the shortcut.
Trait Implementations§
Source§impl<R: Runtime> Display for KeyboardShortcut<R>
impl<R: Runtime> Display for KeyboardShortcut<R>
impl<R: Runtime> Shortcut<R> for KeyboardShortcut<R>
Auto Trait Implementations§
impl<R> Freeze for KeyboardShortcut<R>
impl<R> !RefUnwindSafe for KeyboardShortcut<R>
impl<R> Send for KeyboardShortcut<R>
impl<R> Sync for KeyboardShortcut<R>
impl<R> Unpin for KeyboardShortcut<R>
impl<R> !UnwindSafe for KeyboardShortcut<R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more