Need Sticky Keys macro(s)

I need a macro to enable/disable sticky keys. I use SK a few times a week, and hitting shift five times is easy, but sometimes my iMac boots up without the “five times” box checked. So even if I had a macro to enable the 5Xshift feature, that would be great.

But I also need an instruction to stay on the screen as long as SK is on saying how to turn it off. My wife is not on board with SK, and if I leave the computer with SK on and she needs to look something up, she is driven crazy. Thanks for helping. I’ve constructed a lot of great macros with KM but am not getting anywhere with my attempts at this.

I would like to do the same thing with Mouse Keys, but I don’t use that as much, so I have the 5Xoption feature turned off (it was driving me crazy).

or maybe you need a Macro to "disable sticky keys when device is out of range"? (your iphone or Android phone).

Two problems here:

  1. Displaying a floating message window
  2. Detecting the Sticky Keys setting

1. Displaying a floating window

As far as I know KM has no built-in floating windows. But… you can misuse a palette for this.

So you could…

  1. Set up a periodic macro (e.g. 20s) that tests for the condition (Sticky Keys activated)
  2. If the condition is true --> activate the palette of the macro group

2. Detecting the Sticky Keys setting

The more tricky part. Most likely you can do it with an AppleScript.

(I don’t have the time right now to try it.)

Edit 2016-07-28: Actually not so tricky. This will do:

defaults read com.apple.universalaccess stickyKey

Basically this would look like this:

Sticky Keys Macros.kmmacros (27.8 KB) (Updated with script 2016-07-28.)

You can put other (dummy) macro(s) into the group, where you place a short instruction for turning off Sticky Keys in the macro title. For example:

Sorry that I can’t help you more at the moment, but maybe the idea already helps you a bit.


Edit (2016-07-28):

I’ve added the script for detecting the Sticky Keys setting.

2 Likes

Tom, this is beautiful–thank you. I thought I was going to have to write it step-by-step following your template, but I just downloaded it, imported it, and it works perfectly. I’ve also learned a thing or two about how versatile palettes can be (I’d been meaning to start using them, and this is a perfect time.

Can KM do that? Or can I set that up in IFTTT?

Thanks, guys.

I still am looking for a way to turn on SK even if the checkbox in the Accessibility pane of System Pref is unchecked (I have no idea how it gets unchecked sometimes).

I’ve tried it with setting the userdefaults via

defaults write com.apple.universalaccess stickyKey -bool false

This indeed works, but the non-negligible downside is that it has no (immediate) effect. You probably have to restart a specific background process to make the change effective. Unfortunately I don’t know which. (I’ve tried it with killall Dock; killall SystemUIServer; killall cfprefsd but to no avail.)

Maybe somebody else know…

The other possibility of course is UI scripting. But simply pressing Shift five times seems more elegant to me than launching a clunky UI script.

Here is a version that disables Sticky Keys via UI scripting:

Sticky Keys Macros.kmmacros (53.6 KB)

If it stucks on your computer play with the two delay values in the AppleScript.

The included AppleScript is based on a snippet by Shane Stanley.

Any updates? I also want to toggle sticky keys programmatically.