Skip to content

Commit

Permalink
feat: support Pause/PauseBreak key
Browse files Browse the repository at this point in the history
closes #86
  • Loading branch information
amrbashir committed Oct 29, 2024
1 parent 2636872 commit 8e63b1f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/pause-key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"global-hotkey": patch
---

Support using `Pause` or `PauseBreak` key on Windows and Linux.
1 change: 1 addition & 0 deletions src/hotkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ fn parse_key(key: &str) -> Result<Code, HotKeyParseError> {
"BACKSLASH" | "\\" => Ok(Backslash),
"BRACKETLEFT" | "[" => Ok(BracketLeft),
"BRACKETRIGHT" | "]" => Ok(BracketRight),
"PAUSE" | "PAUSEBREAK" => Ok(Pause),
"COMMA" | "," => Ok(Comma),
"DIGIT0" | "0" => Ok(Digit0),
"DIGIT1" | "1" => Ok(Digit1),
Expand Down
3 changes: 1 addition & 2 deletions src/platform_impl/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ struct HotKeyWrapper {
hotkey: HotKey,
}

// https://macbiblioblog.blogspot.com/2014/12/key-codes-for-function-and-special-keys.html
// can also be found in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h
// can be found in https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.6.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h
pub fn key_to_scancode(code: Code) -> Option<u32> {
match code {
Code::KeyA => Some(0x00),
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ fn key_to_vk(key: &Code) -> Option<VIRTUAL_KEY> {
Code::MediaStop => VK_MEDIA_STOP,
Code::MediaTrackNext => VK_MEDIA_NEXT_TRACK,
Code::MediaTrackPrevious => VK_MEDIA_PREV_TRACK,
Code::Pause => VK_PAUSE,
_ => return None,
})
}
1 change: 1 addition & 0 deletions src/platform_impl/x11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ fn keycode_to_x11_scancode(key: Code) -> Option<u32> {
Code::MediaStop => keysym::XF86XK_AudioStop,
Code::MediaTrackNext => keysym::XF86XK_AudioNext,
Code::MediaTrackPrevious => keysym::XF86XK_AudioPrev,
Code::Pause => keysym::XK_Pause,
_ => return None,
})
}
Expand Down

0 comments on commit 8e63b1f

Please sign in to comment.