pub struct KeyInput {
pub key: String,
pub text: Option<String>,
pub code: Option<String>,
pub key_code: Option<u32>,
pub location: Option<u32>,
pub is_keypad: bool,
}Expand description
Represents a key definition that can be dispatched to the browser.
Fields§
§key: StringDisplay value for the key, for example a or Enter.
text: Option<String>Optional character produced by the key, forwarded to text/unmodifiedText.
code: Option<String>DOM code value used by the browser, when known.
key_code: Option<u32>Platform-specific virtual key code (Windows/native).
location: Option<u32>Keyboard location (0 = Standard, 1 = Left, 2 = Right, 3 = Numpad).
is_keypad: boolMarks whether the key originates from the numeric keypad.
Implementations§
Source§impl KeyInput
impl KeyInput
Sourcepub fn new(key: impl Into<String>) -> Self
pub fn new(key: impl Into<String>) -> Self
Builds a key definition with the given display value.
Sourcepub fn with_text(self, text: impl Into<String>) -> Self
pub fn with_text(self, text: impl Into<String>) -> Self
Sets the character returned by the key.
Sourcepub fn with_key_code(self, key_code: u32) -> Self
pub fn with_key_code(self, key_code: u32) -> Self
Populates the virtual key code.
Sourcepub fn with_location(self, location: u32) -> Self
pub fn with_location(self, location: u32) -> Self
Sets the keyboard location value.
Sourcepub fn from_keypad(self) -> Self
pub fn from_keypad(self) -> Self
Marks the key as originating from the numeric keypad.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KeyInput
impl RefUnwindSafe for KeyInput
impl Send for KeyInput
impl Sync for KeyInput
impl Unpin for KeyInput
impl UnwindSafe for KeyInput
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
Mutably borrows from an owned value. Read more