Closed ericwu17 closed 6 years ago
You can use hs.eventtap.event
to watch for keypresses. You could use hs.timer.doAfter
to remove the observer after a certain period of time.
I'm not really familiar with autohotkey, could you describe a bit more detail about the exact sequence you're looking for?
@cmsj , I want hammerspoon to excecute something after I press some keys in succession, such as when I press D then A then T then E, hammerspoon will press the delete key 4 times and then fill out the current date.
Aha, thanks. So, that is possible using hs.eventtap
, but it's not going to be easy or pretty. Honestly for that specific use-case I think you'd be better off with something like TextExpander. Sorry!
So mor specifically, how would it be done? A single hs.eventtap to watch for the D key, and then how would it detect teh A key being pressed?
You’d create one event tap and listen for all key presses, and keep track of the most recent X number of presses. If the most recent presses match DATE or some other string, fire off some kind of function call to do what you want.
In autohotkey, it is possible to do keywait, which waits for a certain key to be pressed. Is there a way to do this in hammerspoon? I am trying to recreate the hotstrings function of AHK.
Thanks, Eric