hammerspoon
hammerspoon copied to clipboard
Allow empty 'key' in hs.hotkey.new(mods, key, ...)
Hello. I would like to create a key mapping for 'esc' button being pushed twice.
I've first tried the below code, but got error that empty string is not allowed for the 'key' argument.
Code
hs.hotkey.new({"escape", "escape"}, "", ...)
Error log
** Warning:hs.keycode: key '' not found in active keymap or ANSI-standard US keyboard layout
** ERROR : Invalid key: - this may mean that the key requested does not exist in your keymap
(particularly if you switch keyboard layouts frequently)
Putting each 'escape' in the `mods` and `key` only maps **single**, not twice, 'esc' button push.
hs.hotkey.new({"escape"}, "escape", ...)
How do I create a keymap that only takes 2 mods?
I'm not sure I entirely understand your question, however the mods
parameter only supports:
- "cmd", "command" or "⌘"
- "ctrl", "control" or "⌃"
- "alt", "option" or "⌥"
- "shift" or "⇧"
As a result, this: hs.hotkey.new({"escape"}... )
is not valid.
If you want something to trigger if the ESCAPE key is pressed twice, you'd just need to add some logic that detects multiple keypresses within a certain time period using a hs.timer
.