Skip to content

Instantly share code, notes, and snippets.

@kiinoda
Created November 2, 2022 07:47
Show Gist options
  • Save kiinoda/1b1460c4929864881fdf2f8bdeb1e104 to your computer and use it in GitHub Desktop.
Save kiinoda/1b1460c4929864881fdf2f8bdeb1e104 to your computer and use it in GitHub Desktop.
Hammerspoon - press space+left_click on key press (used in Photoshop)
hs.hotkey.bind({"cmd", "ctrl", "alt", "shift"}, "f2",
-- next function is called on hotkey press
function()
hs.eventtap.event.newKeyEvent({}, "space", true):post()
hs.eventtap.event.newMouseEvent(hs.eventtap.event.types["leftMouseDown"], hs.mouse.absolutePosition()):post()
end,
function()
-- next function is called on hotkey release
hs.eventtap.event.newKeyEvent({}, "space", false):post()
hs.eventtap.event.newMouseEvent(hs.eventtap.event.types["leftMouseUp"], hs.mouse.absolutePosition()):post()
end
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment