diff --git a/.changes/pause-key.md b/.changes/pause-key.md new file mode 100644 index 0000000..d60454b --- /dev/null +++ b/.changes/pause-key.md @@ -0,0 +1,5 @@ +--- +"global-hotkey": patch +--- + +Support using `Pause` or `PauseBreak` key on Windows and Linux. diff --git a/src/hotkey.rs b/src/hotkey.rs index def8669..e66c012 100644 --- a/src/hotkey.rs +++ b/src/hotkey.rs @@ -237,6 +237,7 @@ fn parse_key(key: &str) -> Result { "BACKSLASH" | "\\" => Ok(Backslash), "BRACKETLEFT" | "[" => Ok(BracketLeft), "BRACKETRIGHT" | "]" => Ok(BracketRight), + "PAUSE" | "PAUSEBREAK" => Ok(Pause), "COMMA" | "," => Ok(Comma), "DIGIT0" | "0" => Ok(Digit0), "DIGIT1" | "1" => Ok(Digit1), diff --git a/src/platform_impl/macos/mod.rs b/src/platform_impl/macos/mod.rs index 13cc207..b8ac716 100644 --- a/src/platform_impl/macos/mod.rs +++ b/src/platform_impl/macos/mod.rs @@ -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 { match code { Code::KeyA => Some(0x00), diff --git a/src/platform_impl/windows/mod.rs b/src/platform_impl/windows/mod.rs index 137fab4..db5a6b7 100644 --- a/src/platform_impl/windows/mod.rs +++ b/src/platform_impl/windows/mod.rs @@ -303,6 +303,7 @@ fn key_to_vk(key: &Code) -> Option { Code::MediaStop => VK_MEDIA_STOP, Code::MediaTrackNext => VK_MEDIA_NEXT_TRACK, Code::MediaTrackPrevious => VK_MEDIA_PREV_TRACK, + Code::Pause => VK_PAUSE, _ => return None, }) } diff --git a/src/platform_impl/x11/mod.rs b/src/platform_impl/x11/mod.rs index 3c4b449..4eb8496 100644 --- a/src/platform_impl/x11/mod.rs +++ b/src/platform_impl/x11/mod.rs @@ -403,6 +403,7 @@ fn keycode_to_x11_scancode(key: Code) -> Option { Code::MediaStop => keysym::XF86XK_AudioStop, Code::MediaTrackNext => keysym::XF86XK_AudioNext, Code::MediaTrackPrevious => keysym::XF86XK_AudioPrev, + Code::Pause => keysym::XK_Pause, _ => return None, }) }