pub enum KeyCode {
}Expand description
Represents a keyboard key.
This enum covers all keys commonly used in TUI applications, including:
- Alphanumeric characters
- Special keys (Enter, Tab, Esc, etc.)
- Navigation keys (arrows, Home, End, etc.)
- Function keys (F1-F12)
§Example
use ratatui_testlib::events::KeyCode;
let letter = KeyCode::Char('a');
let enter = KeyCode::Enter;
let arrow = KeyCode::Up;
let function = KeyCode::F(1); // F1Variants§
Char(char)
A character key (letters, numbers, symbols).
Enter
Enter key (newline).
Esc
Escape key.
Tab
Tab key.
Backspace
Backspace key.
Delete
Delete key.
Insert
Insert key.
Up
Up arrow key.
Down
Down arrow key.
Left
Left arrow key.
Right
Right arrow key.
Home
Home key.
End
End key.
PageUp
Page Up key.
PageDown
Page Down key.
F(u8)
Function keys F1-F12.
§Example
use ratatui_testlib::events::KeyCode;
let f1 = KeyCode::F(1);
let f12 = KeyCode::F(12);Trait Implementations§
impl Copy for KeyCode
impl Eq for KeyCode
impl StructuralPartialEq for KeyCode
Auto Trait Implementations§
impl Freeze for KeyCode
impl RefUnwindSafe for KeyCode
impl Send for KeyCode
impl Sync for KeyCode
impl Unpin for KeyCode
impl UnwindSafe for KeyCode
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.