File tree 3 files changed +45
-2
lines changed
3 files changed +45
-2
lines changed Original file line number Diff line number Diff line change
1
+ -- Credit for this implementation goes to @arbelt and @jasoncodes 🙇⚡️😻
2
+ --
3
+ -- https://gist.github.com/arbelt/b91e1f38a0880afb316dd5b5732759f1
4
+ -- https://github.com/jasoncodes/dotfiles/blob/ac9f3ac/hammerspoon/control_escape.lua
5
+
6
+ send_escape = false
7
+ last_mods = {}
8
+
9
+ control_key_handler = function ()
10
+ send_escape = false
11
+ end
12
+
13
+ control_key_timer = hs .timer .delayed .new (0.15 , control_key_handler )
14
+
15
+ control_handler = function (evt )
16
+ local new_mods = evt :getFlags ()
17
+ if last_mods [" ctrl" ] == new_mods [" ctrl" ] then
18
+ return false
19
+ end
20
+ if not last_mods [" ctrl" ] then
21
+ last_mods = new_mods
22
+ send_escape = true
23
+ control_key_timer :start ()
24
+ else
25
+ if send_escape then
26
+ hs .eventtap .keyStroke ({}, " ESCAPE" )
27
+ end
28
+ last_mods = new_mods
29
+ control_key_timer :stop ()
30
+ end
31
+ return false
32
+ end
33
+
34
+ control_tap = hs .eventtap .new ({hs .eventtap .event .types .flagsChanged }, control_handler )
35
+ control_tap :start ()
36
+
37
+ other_handler = function (evt )
38
+ send_escape = false
39
+ return false
40
+ end
41
+
42
+ other_tap = hs .eventtap .new ({hs .eventtap .event .types .keyDown }, other_handler )
43
+ other_tap :start ()
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ keyUpDown = function(modifiers, key)
6
6
hs .eventtap .event .newKeyEvent (modifiers , key , false ):post ()
7
7
end
8
8
9
- require (' better-caps-lock ' )
9
+ require (' control-escape ' )
10
10
require (' delete-words' )
11
11
require (' hyper' )
12
12
require (' super' )
Original file line number Diff line number Diff line change 19
19
"name" : " Default profile" ,
20
20
"selected" : true ,
21
21
"simple_modifications" : {
22
- "caps_lock" : " f19 " ,
22
+ "caps_lock" : " left_control " ,
23
23
"right_option" : " f17"
24
24
},
25
25
"virtual_hid_keyboard" : {
You can’t perform that action at this time.
0 commit comments