Skip to main content

Keycode

Struct Keycode 

Source
#[repr(transparent)]
pub struct Keycode(pub u32);
Expand description

A logical keycode — either a Unicode code point or scancode | SCANCODE_MASK.

Tuple Fields§

§0: u32

Implementations§

Source§

impl Keycode

Source

pub const fn new(raw: u32) -> Self

Source

pub const fn raw(self) -> u32

Source

pub const fn from_scancode(sc: Scancode) -> Self

Create a keycode from a scancode (encodes with SCANCODE_MASK).

Source

pub const fn to_scancode(self) -> Option<Scancode>

If this keycode is scancode-encoded, return the scancode portion.

Source

pub fn to_char(self) -> Option<char>

If this keycode is a printable Unicode code point, return it as a char.

Source§

impl Keycode

Common SDLK_* constants. Values identical in SDL2 and SDL3.

Source

pub const UNKNOWN: Keycode

Source

pub const RETURN: Keycode

Source

pub const ESCAPE: Keycode

Source

pub const BACKSPACE: Keycode

Source

pub const TAB: Keycode

Source

pub const SPACE: Keycode

Source

pub const EXCLAIM: Keycode

Source

pub const QUOTEDBL: Keycode

Source

pub const HASH: Keycode

Source

pub const DOLLAR: Keycode

Source

pub const PERCENT: Keycode

Source

pub const AMPERSAND: Keycode

Source

pub const QUOTE: Keycode

Source

pub const LEFTPAREN: Keycode

Source

pub const RIGHTPAREN: Keycode

Source

pub const ASTERISK: Keycode

Source

pub const PLUS: Keycode

Source

pub const COMMA: Keycode

Source

pub const MINUS: Keycode

Source

pub const PERIOD: Keycode

Source

pub const SLASH: Keycode

Source

pub const NUM_0: Keycode

Source

pub const NUM_1: Keycode

Source

pub const NUM_2: Keycode

Source

pub const NUM_3: Keycode

Source

pub const NUM_4: Keycode

Source

pub const NUM_5: Keycode

Source

pub const NUM_6: Keycode

Source

pub const NUM_7: Keycode

Source

pub const NUM_8: Keycode

Source

pub const NUM_9: Keycode

Source

pub const COLON: Keycode

Source

pub const SEMICOLON: Keycode

Source

pub const LESS: Keycode

Source

pub const EQUALS: Keycode

Source

pub const GREATER: Keycode

Source

pub const QUESTION: Keycode

Source

pub const AT: Keycode

Source

pub const LEFTBRACKET: Keycode

Source

pub const BACKSLASH: Keycode

Source

pub const RIGHTBRACKET: Keycode

Source

pub const CARET: Keycode

Source

pub const UNDERSCORE: Keycode

Source

pub const BACKQUOTE: Keycode

Source

pub const A: Keycode

Source

pub const B: Keycode

Source

pub const C: Keycode

Source

pub const D: Keycode

Source

pub const E: Keycode

Source

pub const F: Keycode

Source

pub const G: Keycode

Source

pub const H: Keycode

Source

pub const I: Keycode

Source

pub const J: Keycode

Source

pub const K: Keycode

Source

pub const L: Keycode

Source

pub const M: Keycode

Source

pub const N: Keycode

Source

pub const O: Keycode

Source

pub const P: Keycode

Source

pub const Q: Keycode

Source

pub const R: Keycode

Source

pub const S: Keycode

Source

pub const T: Keycode

Source

pub const U: Keycode

Source

pub const V: Keycode

Source

pub const W: Keycode

Source

pub const X: Keycode

Source

pub const Y: Keycode

Source

pub const Z: Keycode

Source

pub const CAPSLOCK: Keycode

Source

pub const F1: Keycode

Source

pub const F2: Keycode

Source

pub const F3: Keycode

Source

pub const F4: Keycode

Source

pub const F5: Keycode

Source

pub const F6: Keycode

Source

pub const F7: Keycode

Source

pub const F8: Keycode

Source

pub const F9: Keycode

Source

pub const F10: Keycode

Source

pub const F11: Keycode

Source

pub const F12: Keycode

Source

pub const F13: Keycode

Source

pub const F14: Keycode

Source

pub const F15: Keycode

Source

pub const F16: Keycode

Source

pub const F17: Keycode

Source

pub const F18: Keycode

Source

pub const F19: Keycode

Source

pub const F20: Keycode

Source

pub const F21: Keycode

Source

pub const F22: Keycode

Source

pub const F23: Keycode

Source

pub const F24: Keycode

Source

pub const PRINT_SCREEN: Keycode

Source

pub const SCROLL_LOCK: Keycode

Source

pub const PAUSE: Keycode

Source

pub const INSERT: Keycode

Source

pub const HOME: Keycode

Source

pub const PAGE_UP: Keycode

Source

pub const DELETE: Keycode

Source

pub const END: Keycode

Source

pub const PAGE_DOWN: Keycode

Source

pub const RIGHT: Keycode

Source

pub const LEFT: Keycode

Source

pub const DOWN: Keycode

Source

pub const UP: Keycode

Source

pub const NUM_LOCK_CLEAR: Keycode

Source

pub const KP_DIVIDE: Keycode

Source

pub const KP_MULTIPLY: Keycode

Source

pub const KP_MINUS: Keycode

Source

pub const KP_PLUS: Keycode

Source

pub const KP_ENTER: Keycode

Source

pub const KP_1: Keycode

Source

pub const KP_2: Keycode

Source

pub const KP_3: Keycode

Source

pub const KP_4: Keycode

Source

pub const KP_5: Keycode

Source

pub const KP_6: Keycode

Source

pub const KP_7: Keycode

Source

pub const KP_8: Keycode

Source

pub const KP_9: Keycode

Source

pub const KP_0: Keycode

Source

pub const KP_PERIOD: Keycode

Source

pub const KP_EQUALS: Keycode

Source

pub const APPLICATION: Keycode

Source

pub const MENU: Keycode

Source

pub const LCTRL: Keycode

Source

pub const LSHIFT: Keycode

Source

pub const LALT: Keycode

Source

pub const LGUI: Keycode

Source

pub const RCTRL: Keycode

Source

pub const RSHIFT: Keycode

Source

pub const RALT: Keycode

Source

pub const RGUI: Keycode

Trait Implementations§

Source§

impl Clone for Keycode

Source§

fn clone(&self) -> Keycode

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Keycode

Source§

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

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

impl From<Keycode> for u32

Source§

fn from(value: Keycode) -> Self

Converts to this type from the input type.
Source§

impl From<char> for Keycode

Source§

fn from(c: char) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Keycode

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl Hash for Keycode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Keycode

Source§

fn cmp(&self, other: &Keycode) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Keycode

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Keycode

Source§

fn partial_cmp(&self, other: &Keycode) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Keycode

Source§

impl Eq for Keycode

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.