Skip to content

Commit

Permalink
Prefer camelCase to snake_case
Browse files Browse the repository at this point in the history
I was reading through a previous pull request and saw the request for
the use of camelCase instead of snake_case. This file was pointed to as
needing to be updated. Here's the update :)
  • Loading branch information
landongrindheim committed Oct 27, 2018
1 parent 72998c1 commit c0e915b
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions hammerspoon/control-escape.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@
-- https://gist.github.com/arbelt/b91e1f38a0880afb316dd5b5732759f1
-- https://github.com/jasoncodes/dotfiles/blob/ac9f3ac/hammerspoon/control_escape.lua

send_escape = false
last_mods = {}
sendEscape = false
lastMods = {}

control_key_handler = function()
send_escape = false
controlKeyHandler = function()
sendEscape = false
end

control_key_timer = hs.timer.delayed.new(0.15, control_key_handler)
controlKeyTimer = hs.timer.delayed.new(0.15, controlKeyHandler)

control_handler = function(evt)
local new_mods = evt:getFlags()
if last_mods["ctrl"] == new_mods["ctrl"] then
controlHandler = function(evt)
local newMods = evt:getFlags()
if lastMods["ctrl"] == newMods["ctrl"] then
return false
end
if not last_mods["ctrl"] then
last_mods = new_mods
send_escape = true
control_key_timer:start()
if not lastMods["ctrl"] then
lastMods = newMods
sendEscape = true
controlKeyTimer:start()
else
if send_escape then
if sendEscape then
keyUpDown({}, 'escape')
end
last_mods = new_mods
control_key_timer:stop()
lastMods = newMods
controlKeyTimer:stop()
end
return false
end

control_tap = hs.eventtap.new({hs.eventtap.event.types.flagsChanged}, control_handler)
control_tap:start()
controlTap = hs.eventtap.new({hs.eventtap.event.types.flagsChanged}, controlHandler)
controlTap:start()

other_handler = function(evt)
send_escape = false
otherHandler = function(evt)
sendEscape = false
return false
end

other_tap = hs.eventtap.new({hs.eventtap.event.types.keyDown}, other_handler)
other_tap:start()
otherTap = hs.eventtap.new({hs.eventtap.event.types.keyDown}, otherHandler)
otherTap:start()

0 comments on commit c0e915b

Please sign in to comment.