#[repr(C)]pub struct KeyEvent {
pub text: SharedString,
pub modifiers: KeyboardModifiers,
pub repeat: bool,
pub event_type: KeyEventType,
pub replacement_range: Option<Range<i32>>,
pub preedit_text: SharedString,
pub preedit_selection: Option<Range<i32>>,
pub cursor_position: Option<i32>,
pub anchor_position: Option<i32>,
}Expand description
This structure is generated and passed to the key press and release callbacks of the FocusScope element.
Fields§
§text: SharedStringThe unicode representation of the key pressed.
modifiers: KeyboardModifiersThe keyboard modifiers active at the time of the key press event.
repeat: boolThis field is set to true for key press events that are repeated, i.e. the key is held down. It’s always false for key release events.
event_type: KeyEventTypeIndicates whether the key was pressed or released
replacement_range: Option<Range<i32>>If the event type is KeyEventType::UpdateComposition or KeyEventType::CommitComposition, then this field specifies what part of the current text to replace. Relative to the offset of the pre-edit text within the text input element’s text.
preedit_text: SharedStringIf the event type is KeyEventType::UpdateComposition, this is the new pre-edit text
preedit_selection: Option<Range<i32>>The selection within the preedit_text
cursor_position: Option<i32>The new cursor position, when None, the cursor is put after the text that was just inserted
anchor_position: Option<i32>Implementations§
Source§impl KeyEvent
impl KeyEvent
Sourcepub fn shortcut(&self) -> Option<StandardShortcut>
pub fn shortcut(&self) -> Option<StandardShortcut>
If a shortcut was pressed, this function returns Some(StandardShortcut).
Otherwise it returns None.
Sourcepub fn text_shortcut(&self) -> Option<TextShortcut>
pub fn text_shortcut(&self) -> Option<TextShortcut>
If a shortcut concerning text editing was pressed, this function
returns Some(TextShortcut). Otherwise it returns None.