Skip to content

Instantly share code, notes, and snippets.

@jshbrntt
Created February 2, 2017 14:27
Show Gist options
  • Save jshbrntt/efa9caeb79521437524973d683c96063 to your computer and use it in GitHub Desktop.
Save jshbrntt/efa9caeb79521437524973d683c96063 to your computer and use it in GitHub Desktop.
Hammerspoon - Bind Scroll Wheel Left/Right to Ctrl+Left/Right (move spaces)
doKeyStroke = function(modifiers, character)
local event = require("hs.eventtap").event
event.newKeyEvent(modifiers, string.lower(character), true):post()
event.newKeyEvent(modifiers, string.lower(character), false):post()
end
hs.eventtap.new({hs.eventtap.event.types.scrollWheel}, function(e)
scrollWheelClick = e:getProperty(hs.eventtap.event.properties.scrollWheelEventDeltaAxis2)
if scrollWheelClick > 0 then
doKeyStroke({'ctrl'}, 'left')
elseif scrollWheelClick < 0 then
doKeyStroke({'ctrl'}, 'right')
end
end):start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment