Skip to content

Instantly share code, notes, and snippets.

@chrismytton
Created March 5, 2017 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismytton/74fb2d15aaff656b5ffdd41ba95f1ec0 to your computer and use it in GitHub Desktop.
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)"
-- 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