hammerspoon
hammerspoon copied to clipboard
Mission control related shortcuts do not work on macOS Mojave
After updating to macOS Mojave (10.14), I could no longer get hammerspoon to execute key-binds that access mission control
hs.eventtap.keyStroke({"ctrl"}, "up")
or switch desktops
hs.eventtap.keyStroke({"ctrl"}, "left")
hs.eventtap.keyStroke({"ctrl"}, "right")
These commands worked fine in Yosemite, Sierra and High Sierra.
Not working here either. Doh! Any ideas @cmsj or @asmagill ?
Maybe related:
https://twitter.com/keyboardmaestro/status/1045233448317726720
I got this same error both on Keyboard Maestro and Hammerspoon, use applescript fix temporarily:
hs.osascript.applescript("tell application \"System Events\" to key code 123 using control down")
Nice workaround @Voleking !
FYI: I tried all the steps listed here with Hammerspoon, but none of them seemed to work sadly.
I also tried giving Hammerspoon "Full Disk Access", but no luck.
Possibly related? https://stackoverflow.com/a/52386903/6925202
I wonder if the only solution is to re-write hs.eventtap
- as I know this is something @asmagill has talked about for a while (#1161)?
Hyper's window summon extension doesn't like this, either. I set Hyper to react to F18, which has stopped working after switching to Mojave. This is my Hammerspoon line:
hs.eventtap.keyStroke({}, 'F18')
Haven't had the issue. Does adding a 0 delay fix?
hs.eventtap.keyStroke({"ctrl"},dir,0)
Try adding "fn"
as a modifier. hs.eventtap.keyStroke({"fn", "cmd"},"left",100)
works where hs.eventtap.keyStroke({"cmd"},"left",100)
doesn't.
Encountered the same problem. Ctrl with numbers like C-1 still work, but Ctrl with arrows like C-Right don't. Hammerspoon just fails to trigger hs.eventtap.keyStroke({ 'ctrl' }, 'right')
(I set C-Right to Misson Control -> Move right a space)
This breaks my space switch setup, https://github.com/Hammerspoon/hammerspoon/issues/823#issuecomment-193008104
The same profile does work on Sierra and High Sierra, it only breaks in Mojave. I haven't tried newer version of macOS yet.
Same issue here on Monterey. The fn
trick works.
The fn trick really works. How does adding fn fix it? @MynockSpit
No idea. 😆 I don't think I ever knew, but if I did, it's lost in the sands of time.
The arrow keys are considered "fn" keys by the mac os (as well as a few other non-printables though I can't recall which specifically at the moment) and have been as far back as I can recall... you can verify this yourself by setting up an eventtap to capture keyUp/keyDown events that prints the modifier flags to the console of the various keys as you type them.
As to why previous OS versions didn't require setting this flag when generating synthetic arrow key events I can't say... but the trick is consistent with what the OS does itself.
Try adding
"fn"
as a modifier.hs.eventtap.keyStroke({"fn", "cmd"},"left",100)
works wherehs.eventtap.keyStroke({"cmd"},"left",100)
doesn't.
This works, I suggest adding a warning to Hammerspoon where the key to be pressed is an arrow or function key, and close this issue.