pub trait PhysicalKeyExtScancode {
    // Required methods
    fn to_scancode(self) -> Option<u32>;
    fn from_scancode(scancode: u32) -> PhysicalKey;
}
Available on windows_platform or macos_platform or x11_platform or wayland_platform only.
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 succesful; 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.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl PhysicalKeyExtScancode for KeyCode

source§

impl PhysicalKeyExtScancode for PhysicalKey

Available on (x11_platform or wayland_platform) and free_unix only.