-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtaps_keyUp.lua
30 lines (26 loc) · 1.25 KB
/
taps_keyUp.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- -------------------------------------------------------------------------------------
-- Trap keyUp
-- -------------------------------------------------------------------------------------
-- This eventtap is set by binding scripts that need to block other keyboard events the
-- user or the OS generates while script is executing
etKeyUp = hs.eventtap.new({hs.eventtap.event.types.keyUp}, function (e)
log('keyUp event: keycode=' .. tostring(e:getKeyCode()) .. '; userdata=' .. tostring(e:getProperty(EVENTPROPERTY_EVENTSOURCEUSERDATA)) .. "; semaphore=" .. tostring(semaphore) .. '; flags=' .. hs.inspect(e:getFlags()))
-- If a scripted action needed to block other keyboard events, then look
-- for a key up event from the last event in the scripted chain of events
-- and disable the event shunt eventtap and this eventtap
--[[]
if e:getProperty(EVENTPROPERTY_EVENTSOURCEUSERDATA) == 55556 then
--log('Disabling shunt')
ekKeyDownShuntCtrl:stop()
etKeyUp:stop()
-- Clear any flags. This may not be good in case of repeats
--e:setFlags({})
--log('Unset flags. flags=' .. hs.inspect(e:getFlags()))
end
]]
if repeatMode then
repeatMode = false
hs.alert('Repeat OFF')
return false -- Let event go through
end
end):start()