Skip to main content

KbdKeyExt

Trait KbdKeyExt 

Source
pub trait KbdKeyExt: Sealed {
    // Required method
    fn to_key_code(self) -> KeyCode;
}
Expand description

Extension trait on kbd::key::Key for converting to evdev::KeyCode.

Key::UNIDENTIFIED and any key without a known evdev equivalent maps to KeyCode::KEY_UNKNOWN.

This trait is sealed and cannot be implemented outside this crate.

Required Methods§

Source

fn to_key_code(self) -> KeyCode

Convert this key to an evdev KeyCode.

Key::UNIDENTIFIED maps to KeyCode::KEY_UNKNOWN.

§Examples
use evdev::KeyCode;
use kbd::prelude::*;
use kbd_evdev::KbdKeyExt;

assert_eq!(Key::A.to_key_code(), KeyCode::KEY_A);
assert_eq!(Key::CONTROL_LEFT.to_key_code(), KeyCode::KEY_LEFTCTRL);

// UNIDENTIFIED maps to KEY_UNKNOWN
assert_eq!(Key::UNIDENTIFIED.to_key_code(), KeyCode::KEY_UNKNOWN);

Implementations on Foreign Types§

Source§

impl KbdKeyExt for Key

Implementors§