Struct patternfly_dioxus::dioxus_elements::on::KeyboardData
[−]pub struct KeyboardData {
pub char_code: u32,
pub key: String,
pub key_code: KeyCode,
pub alt_key: bool,
pub ctrl_key: bool,
pub meta_key: bool,
pub shift_key: bool,
pub locale: String,
pub location: usize,
pub repeat: bool,
pub which: usize,
}Fields
char_code: u32key: StringIdentify which “key” was entered.
This is the best method to use for all languages. They key gets mapped to a String sequence which you can match on. The key isn’t an enum because there are just so many context-dependent keys.
A full list on which keys to use is available at: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
Example
match event.key().as_str() {
"Esc" | "Escape" => {}
"ArrowDown" => {}
"ArrowLeft" => {}
_ => {}
}key_code: KeyCodeGet the key code as an enum Variant.
This is intended for things like arrow keys, escape keys, function keys, and other non-international keys.
To match on unicode sequences, use the [KeyboardEvent::key] method - this will return a string identifier instead of a limited enum.
Example
use dioxus::KeyCode;
match event.key_code() {
KeyCode::Escape => {}
KeyCode::LeftArrow => {}
KeyCode::RightArrow => {}
_ => {}
}alt_key: boolIndicate if the alt modifier key was pressed during this keyboard event
ctrl_key: boolIndicate if the ctrl modifier key was pressed during this keyboard event
meta_key: boolIndicate if the meta modifier key was pressed during this keyboard event
shift_key: boolIndicate if the shift modifier key was pressed during this keyboard event
locale: Stringlocation: usizerepeat: boolwhich: usizeTrait Implementations
impl Clone for KeyboardData
impl Clone for KeyboardData
fn clone(&self) -> KeyboardData
fn clone(&self) -> KeyboardData
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source. Read more