Replies: 2 comments
-
I also did wrote me a function for using fn to double tap to execute a function... May be this function helps you a little bit more. I check the flags and the key code. So you may need to adjust it a little bit. Oh and for your code a tip: add a local localTime = 0
local fnCounter = 0
local function keyDownHandler(event)
local flags = event:getFlags()
local characters = event:getCharacters(true)
local keyCode = event:getKeyCode()
-- Check for pressing FN two times to disable/enable Audioinput
if flags['fn'] and not flags['cmd'] and not flags['ctrl'] and not flags['alt'] and keyCode == 63 then
if (hs.timer.localTime() - localTime) >= 2 then
fnCounter = 0
end
if fnCounter == 0 then
localTime = hs.timer.localTime()
end
fnCounter = fnCounter + 1
-- print('down',fnCounter)
-- print(keyCode)
end
if not flags['fn'] and not flags['cmd'] and not flags['ctrl'] and not flags['alt'] and keyCode == 63 then
-- print('up')
fnCounter = fnCounter + 1
if (hs.timer.localTime() - localTime) < 2 then
-- pess two times fn and then change audioinput
if fnCounter == 4 then
fnCounter = 0
-- insert here function call
print('double fn pressed')
end
else
fnCounter = 0
end
-- print(keyCode)
end
end
keyDownEventListener = hs.eventtap.new({
hs.eventtap.event.types.flagsChanged,
hs.eventtap.event.types.keyDown
}, keyDownHandler)
keyDownEventListener:start() |
Beta Was this translation helpful? Give feedback.
-
That won't work for modifier keys. See #1025 (comment). The DoubleTapControl = eventtap.new({ event.keyDown }, function(event)
...
end):start() |
Beta Was this translation helpful? Give feedback.
-
I found this link that shows how to handle double click on a key https://stackoverflow.com/a/44350843/5458200
I am trying to handle ctrl double click but it's not working:
Any ideas what I am doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions