Skip to main content

KeyCode

Enum KeyCode 

Source
pub enum KeyCode {
Show 27 variants Char(char), Enter, Backspace, Tab, Escape, Left, Right, Up, Down, Home, End, BackTab, PageUp, PageDown, Insert, Delete, KeypadBegin, CapsLock, ScrollLock, NumLock, PrintScreen, Pause, Menu, Null, Function(u8), Modifier(ModifierKeyCode), Media(MediaKeyCode),
}
Expand description

The key identity reported by the terminal.

Variants§

§

Char(char)

A Unicode character key after terminal decoding.

Termina stores the character it can identify from the input source rather than normalizing every alphabetic key to lowercase plus Modifiers::SHIFT. For ordinary UTF-8 terminal input, A is reported as Char('A') and Shift is also recorded in modifiers when Termina can infer it from the decoded character. Control bytes such as Ctrl+A are reported as Char('a') with Modifiers::CONTROL. Enhanced keyboard protocols and the Windows backend may use layout-aware or protocol-supplied characters, so callers should compare against the character they want to handle instead of assuming another terminal library’s capitalization model.

§

Enter

The Enter or Return key.

§

Backspace

The Backspace key.

§

Tab

The Tab key.

§

Escape

The Escape key.

§

Left

The left arrow key.

§

Right

The right arrow key.

§

Up

The up arrow key.

§

Down

The down arrow key.

§

Home

The Home key.

§

End

The End key.

§

BackTab

Shift+Tab or another backwards-tab key sequence.

§

PageUp

The Page Up key.

§

PageDown

The Page Down key.

§

Insert

The Insert key.

§

Delete

The Delete key.

§

KeypadBegin

The keypad begin key.

§

CapsLock

The Caps Lock key.

§

ScrollLock

The Scroll Lock key.

§

NumLock

The Num Lock key.

§

PrintScreen

The Print Screen key.

§

Pause

The Pause or Break key.

§

Menu

The Menu or Application key.

§

Null

A null key code.

This can appear when a platform backend reports a key event without a printable or named key identity.

§

Function(u8)

F1-F35 function keys.

§

Modifier(ModifierKeyCode)

A modifier key such as Shift, Control, Alt, Super, Hyper, or Meta.

§

Media(MediaKeyCode)

A media control key.

Trait Implementations§

Source§

impl Clone for KeyCode

Source§

fn clone(&self) -> KeyCode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for KeyCode

Source§

impl Debug for KeyCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for KeyCode

Source§

impl From<KeyCode> for KeyEvent

Source§

fn from(code: KeyCode) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for KeyCode

Source§

fn eq(&self, other: &KeyCode) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for KeyCode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.