Created
March 5, 2017 12:26
-
-
Save chrismytton/74fb2d15aaff656b5ffdd41ba95f1ec0 to your computer and use it in GitHub Desktop.
Hammerspoon version of Karabiner's "Control_L to Control_L (+ when you type Control_L only, send escape)"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Send escape when ctrl is tapped | |
local send_escape = false | |
local ctrl_pressed = false | |
hs.eventtap.new({hs.eventtap.event.types.flagsChanged}, function(event) | |
local flags = event:getFlags() | |
if flags["ctrl"] then | |
ctrl_pressed = true | |
send_escape = true | |
else | |
if ctrl_pressed and send_escape then | |
hs.eventtap.keyStroke({}, 'ESCAPE') | |
end | |
send_escape = false | |
ctrl_pressed = false | |
end | |
return false | |
end):start() | |
hs.eventtap.new({hs.eventtap.event.types.keyDown}, function(event) | |
send_escape = false | |
return false | |
end):start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment