Skip to main content

EvdevKeyCodeExt

Trait EvdevKeyCodeExt 

Source
pub trait EvdevKeyCodeExt: Sealed {
    // Required method
    fn to_key(self) -> Key;
}
Expand description

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

Returns Key::UNIDENTIFIED for key codes that have no kbd mapping (e.g., KEY_PROG2, KEY_COFFEE).

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

Required Methods§

Source

fn to_key(self) -> Key

Convert this evdev key code to a Key.

Returns Key::UNIDENTIFIED for key codes that don’t have a mapping.

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

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

// Unmapped codes return UNIDENTIFIED
assert_eq!(KeyCode::KEY_PROG2.to_key(), Key::UNIDENTIFIED);

Implementations on Foreign Types§

Source§

impl EvdevKeyCodeExt for KeyCode

Source§

fn to_key(self) -> Key

Implementors§