From b4536a7dcc3017d53eb60f350d19b0d88a61c25b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 19 May 2021 10:35:17 -0400 Subject: [PATCH] isolate escape from trackpad --- .../Spoons/ControlEscape.spoon/init.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua index c8e6713..a10ed86 100644 --- a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua +++ b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua @@ -63,6 +63,20 @@ function obj:init() self.sendEscape = false end ) + + -- If mouse is moving, don't send escape + self.scrolling = hs.eventtap.new({hs.eventtap.event.types.gesture}, + function(event) + local touches = event:getTouches() + local i, v = next(touches, nil) + while i do + if v["phase"] == "moved" then + self.sendEscape = false + end + i, v = next(touches, i) -- get next index + end + end + ) end --- ControlEscape:start() @@ -71,6 +85,7 @@ end function obj:start() self.controlTap:start() self.asModifier:start() + self.scrolling:start() end --- ControlEscape:stop() @@ -80,6 +95,7 @@ function obj:stop() -- Stop monitoring keystrokes self.controlTap:stop() self.asModifier:stop() + self.scrolling:stop() -- Reset state self.sendEscape = false