rio_window::platform::scancode

Trait PhysicalKeyExtScancode

Source
pub trait PhysicalKeyExtScancode {
    // Required methods
    fn to_scancode(self) -> Option<u32>;
    fn from_scancode(scancode: u32) -> PhysicalKey;
}
Expand description

Additional methods for the PhysicalKey type that allow the user to access the platform-specific scancode.

Required Methods§

Source

fn to_scancode(self) -> Option<u32>

The raw value of the platform-specific physical key identifier.

Returns Some(key_id) if the conversion was successful; returns None otherwise.

§Platform-specific
  • Windows: A 16bit extended scancode
  • Wayland/X11: A 32-bit linux scancode, which is X11/Wayland keycode subtracted by 8.
Source

fn from_scancode(scancode: u32) -> PhysicalKey

Constructs a PhysicalKey from a platform-specific physical key identifier.

Note that this conversion may be lossy, i.e. converting the returned PhysicalKey back using to_scancode might not yield the original value.

§Platform-specific
  • Wayland/X11: A 32-bit linux scancode. When building from X11/Wayland keycode subtract 8 to get the value you wanted.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§