Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/platform/windows/keycode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ pub fn vk_to_key(vk_code: u16, is_extended: bool) -> Option<Key> {
0x38 => Some(Key::Num8),
0x39 => Some(Key::Num9),

// Media keys
0xB3 => Some(Key::PlayPause),
0xB2 => Some(Key::Stop),
0xB1 => Some(Key::PrevTrack),
0xB0 => Some(Key::NextTrack),

// Numpad keys - these are always distinct from main keys
vk::NUMPAD0 => Some(Key::Keypad0),
vk::NUMPAD1 => Some(Key::Keypad1),
Expand Down
16 changes: 16 additions & 0 deletions src/types/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ pub enum Key {
Num8,
Num9,

// Media keys
PlayPause,
Stop,
PrevTrack,
NextTrack,

// Function keys
F1,
F2,
Expand Down Expand Up @@ -185,6 +191,10 @@ impl fmt::Display for Key {
Key::Num7 => write!(f, "7"),
Key::Num8 => write!(f, "8"),
Key::Num9 => write!(f, "9"),
Key::PlayPause => write!(f, "PlayPause"),
Key::Stop => write!(f, "Stop"),
Key::PrevTrack => write!(f, "PrevTrack"),
Key::NextTrack => write!(f, "NextTrack"),
Key::F1 => write!(f, "F1"),
Key::F2 => write!(f, "F2"),
Key::F3 => write!(f, "F3"),
Expand Down Expand Up @@ -314,6 +324,12 @@ impl FromStr for Key {
"8" | "num8" => Ok(Key::Num8),
"9" | "num9" => Ok(Key::Num9),

// Media keys
"playpause" => Ok(Key::PlayPause),
"stop" => Ok(Key::Stop),
"prevtrack" => Ok(Key::PrevTrack),
"nexttrack" => Ok(Key::NextTrack),

// Function keys
"f1" => Ok(Key::F1),
"f2" => Ok(Key::F2),
Expand Down