pub struct KeyMsg {
pub key_type: KeyType,
pub runes: Vec<char>,
pub alt: bool,
pub paste: bool,
}Expand description
Keyboard key event message.
KeyMsg is sent to the program’s update function when a key is pressed.
§Example
use bubbletea::{KeyMsg, KeyType};
fn handle_key(key: KeyMsg) {
match key.key_type {
KeyType::Enter => println!("Enter pressed"),
KeyType::Runes => println!("Typed: {:?}", key.runes),
_ => {}
}
}Fields§
§key_type: KeyTypeThe type of key pressed.
runes: Vec<char>For KeyType::Runes, the characters typed.
alt: boolWhether Alt was held.
paste: boolWhether this came from a paste operation.
Implementations§
Source§impl KeyMsg
impl KeyMsg
Sourcepub fn from_runes(runes: Vec<char>) -> Self
pub fn from_runes(runes: Vec<char>) -> Self
Create a new key message from multiple characters (e.g., from IME).
Sourcepub fn with_paste(self) -> Self
pub fn with_paste(self) -> Self
Set the paste flag.
Trait Implementations§
impl Eq for KeyMsg
impl StructuralPartialEq for KeyMsg
Auto Trait Implementations§
impl Freeze for KeyMsg
impl RefUnwindSafe for KeyMsg
impl Send for KeyMsg
impl Sync for KeyMsg
impl Unpin for KeyMsg
impl UnwindSafe for KeyMsg
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