I'm not familiar with LUA or hammerspoon, but I want to listen for any button on the keyboard being pressed.
I believe I can use hs.eventtap.event.newKeyEvent
for this, but I'm not sure how to catch any and all key press. I don't care what is pressed, I just want to mute the microphone, and unmute it once there has been x
number of seconds of no key being pressed.
Is this possible with hammerspoon? Please point me in the right direction.
I use the following to toggle my audio input devices between muted and unmuted.
That will toggle between muted and unmuted when you press ⌥+⌃+m.
If you want to automatically mute after X seconds of no keyboard activity, then have a look at the
hs.eventtap
documentation.https://www.hammerspoon.org/docs/hs.eventtap.event.html
You could set up a listener for key up (
keyUp
) or key down (key down
) events.To accomplish this:
keyDown
event typeOnce the timer has triggered it will mute the audio input devices and stop the timer. After that as soon as you press a key on the keyboard the timer will be restarted.
For example:
Reacting to mouse events is similar.