Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Oneechan69

macrumors regular
Original poster
Mar 29, 2022
234
29
US
Edit: I looked at Sticky Keys in settings but it only stays down for one keystroke, I want to keep the modifier keys held down.

Basically I want to toggle modifier keys on and off like how caps lock works.

For instance, if I press CMD then it stays pressed down on macOS (toggled on), so if I press a letter like H after that, it does CMD H, and if I press CMD again then the key will stop being held (toggled off). I really wanna try this out because it actually takes a split second longer to press hotkeys with modifiers because you have to make sure the modifier(s) are held down before pressing non-modifier keys.

I'd also like to use the ESC key to toggle off all modifiers, after using hotkeys with multiple modifiers.
 
Last edited:

zevrix

macrumors 6502
Oct 10, 2012
293
178
For instance, if I press CMD then it stays pressed down on macOS (toggled on), so if I press a letter like H after that, it does CMD H, and if I press CMD again then the key will stop being held (toggled off). I really wanna try this out because it actually takes a split second longer to press hotkeys with modifiers because you have to make sure the modifier(s) are held down before pressing non-modifier keys.

I think you'll be better served by a macro utility such as Keyboard Maestro. (Or maybe built-in Shortcuts can do that, too.)

There, you'll be able to create sequences of shortcuts that you'll be able to call with a single key. For example, call a Cmd-I, Cmd-F sequence with a single key.

In all likelihood, you're calling the same pattern of sequences all the time anyway, so you'll be able to create several pre-defined sequences for what you need.

Yes, it will require you to assign completely new shortcuts to your sequences (which is something you probably want to avoid), but in the end you'll achieve what you need to execute your sequences with minimal effort.
 

f54da

macrumors 6502
Dec 22, 2021
449
154
If you're comfortable coding, doing what you want should be possible with use of the EventTap API and CGEventPost
 

gilby101

macrumors 68030
Mar 17, 2010
2,690
1,460
Tasmania
For instance, if I press CMD then it stays pressed down on macOS (toggled on), so if I press a letter like H after that, it does CMD H, and if I press CMD again then the key will stop being held (toggled off). I really wanna try this out because it actually takes a split second longer to press hotkeys with modifiers because you have to make sure the modifier(s) are held down before pressing non-modifier keys.
For this you need an app which can inspect every keystroke and take action accordingly. Will need to a) if CMD/Opt/Ctrl, toggle flag on or off, and b) everything else: intercept the keystroke and then if flag is set do cmd-letter, otherwise pass on letter. I expect you could do this with Keyboard Maestro, but would it introduce slight delays in all typing?
 

f54da

macrumors 6502
Dec 22, 2021
449
154
CGEventTap should not introduce any major delay, bunch of apps (e.g. BTT) already register an event tap for every keystroke and it doesn't affect latency much. Also I misspoke you don't need to post any event, just modify the existing event to set the flag bits accordingly.
 
  • Like
Reactions: zevrix and gilby101
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.