Skip to content

Instantly share code, notes, and snippets.

@chrismytton
Created March 5, 2017 12:26
Show Gist options
  • Save chrismytton/74fb2d15aaff656b5ffdd41ba95f1ec0 to your computer and use it in GitHub Desktop.
Save chrismytton/74fb2d15aaff656b5ffdd41ba95f1ec0 to your computer and use it in GitHub Desktop.

Revisions

  1. chrismytton created this gist Mar 5, 2017.
    23 changes: 23 additions & 0 deletions init.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    -- 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()