Struct KeyboardShortcut

Source
pub struct KeyboardShortcut { /* private fields */ }

Implementations§

Source§

impl KeyboardShortcut

Source

pub fn new(key: impl AsRef<str>) -> Self

Source

pub fn builder(key: impl AsRef<str>) -> KeyboardShortcutBuilder

Initialize a new keyboard shortcut builder with the specified key.

Source

pub fn with_modifiers(key: impl AsRef<str>, modifiers: &[ModifierKey]) -> Self

Create a new keyboard shortcut with the specified key and modifiers.

Source

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();
Source

pub fn with_ctrl(key: impl AsRef<str>) -> Self

Create a new keyboard shortcut with the specified key and the CtrlKey modifier.

Source

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.

Source

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.

Source

pub fn with_meta(key: impl AsRef<str>) -> Self

Create a new keyboard shortcut with the specified key and the MetaKey modifier.

Source

pub fn with_shift(key: impl AsRef<str>) -> Self

Create a new keyboard shortcut with the specified key and the ShiftKey modifier.

Source

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.

Source

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.

Source

pub fn key(&self) -> &str

The key of the shortcut.

Source

pub fn modifiers(&self) -> &[ModifierKey]

The modifiers of the shortcut.

Trait Implementations§

Source§

impl Debug for KeyboardShortcut

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for KeyboardShortcut

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Shortcut for KeyboardShortcut

Source§

fn kind(&self) -> ShortcutKind<'_>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,