hammerspoon icon indicating copy to clipboard operation
hammerspoon copied to clipboard

Mission control related shortcuts do not work on macOS Mojave

Open Jono-Chang opened this issue 5 years ago • 14 comments

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.

Jono-Chang avatar Sep 26 '18 12:09 Jono-Chang

Not working here either. Doh! Any ideas @cmsj or @asmagill ?

latenitefilms avatar Sep 26 '18 13:09 latenitefilms

Maybe related:

https://twitter.com/keyboardmaestro/status/1045233448317726720

latenitefilms avatar Sep 29 '18 02:09 latenitefilms

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")

tshu-w avatar Sep 30 '18 07:09 tshu-w

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)?

latenitefilms avatar Sep 30 '18 08:09 latenitefilms

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')

TheBaronHimself avatar Nov 08 '18 22:11 TheBaronHimself

Haven't had the issue. Does adding a 0 delay fix?

      hs.eventtap.keyStroke({"ctrl"},dir,0)

jdtsmith avatar Dec 11 '18 16:12 jdtsmith

Try adding "fn" as a modifier. hs.eventtap.keyStroke({"fn", "cmd"},"left",100) works where hs.eventtap.keyStroke({"cmd"},"left",100) doesn't.

MynockSpit avatar Dec 22 '18 23:12 MynockSpit

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.

laggardkernel avatar Oct 23 '21 09:10 laggardkernel

Same issue here on Monterey. The fn trick works.

jdtsmith avatar Mar 15 '22 01:03 jdtsmith

The fn trick really works. How does adding fn fix it? @MynockSpit

gineer01 avatar Feb 20 '23 03:02 gineer01

No idea. 😆 I don't think I ever knew, but if I did, it's lost in the sands of time.

MynockSpit avatar Feb 20 '23 18:02 MynockSpit

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.

asmagill avatar Feb 20 '23 19:02 asmagill

Try adding "fn" as a modifier. hs.eventtap.keyStroke({"fn", "cmd"},"left",100) works where hs.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.

NightMachinery avatar Jan 10 '24 03:01 NightMachinery