Do you try just moving the "Type a Space" action out of the second "If" block and up to the "execute" section of the first "If"?
Edit to add:
Also, consider changing that first test. You don't really want to test the current state, you want to test the trigger that fired the macro. So something like:
Hi Nige, I honestly don't understand what you mean and I don't see your screenshot, I just see a gray area. If you have time, I would be very grateful for a finished macro. Only if you can.
I would normally do this with BTT, but there has been a bug there for years that prevents this from working.
The trouble is, if you hold the space bar too long, it starts to repeat (if you have that option on in macOS prefs) and the palette disappears.
What if you don't want a space to be typed every time you call a palette? It would play media or type errant spaces. Presumably, you're only using this in an app where this isn't an issue...?
Thank you @noisneil I put my palette in your macro, but unfortunately it doesn't appear. And you are right, space always repeats itself, hmm. Is there no way to type space only once? ... I could try to disable key repeat in macos.
Ah, how do I post a macro?
I'll delete that then. The important thing is that "space" is typed when the key is pressed, not when it is released. You know the reason for this
This is the bit I'm struggling with. @Frankb, have you turned off "Key repeat" in System Preferences/Settings? If not, I'm not sure you can do what you want.
System Preferences/Settings -> Keyboard, "Key repeat rate" will be set to "Off". Or if you mean "what does turning it off change" -- holding down a key will no longer repeat. That's not such a thing these days, now that holding down eg the E key brings up the "accented characters" box rather than typing eeeeeeeee, but it'll really depend on your personal settings.
Rather than type it then delete it, just move the "Type a Space" from the top into the "otherwise" section of the "If" action -- then it will only be typed when the palette doesn't appear:
Thanks Nige, in V2 "space" is typed when the key is released. Unfortunately this does not work for me. I write too fast, that leads to character twists.
But the "delete" solution is good enough for me. Thanks again to both of you.
Edit // In fact, there is one key where I need the key repeat ... Delete. I thought I could solve it this way, but it doesn't work. I'll see if BTT can do it.
Was forgetting that. I was allowing for slow typers (like me!), who could have problems when doing it your way. What works for you works for you -- go for it!
That'll only trigger once when the key is pressed, doing one delete -- you want to do a delete then repeat until the key is released. Set the pause to match your preferred repeat rate:
KM macros are triggered by events -- in this case, the "key down" event for the Delete key. The event is fired once, when the thing happens, so when you press the Delete key down the macro triggers -- it doesn't keep triggering if you hold the key down.
What a load of nonsense I talk! As @Frankb has pointed out, that would be true for the "key pressed" trigger, but "key down" should trigger the macro repeatedly.
But the Conditional checks the state of the key -- "is the Delete key down?" -- and the "While" repeats for as long as the condition is true, sending the simulated Delete once every loop.
So while the wording in your screenshots is similar, the way they are read is different -- "when the Delete key goes from up to down" versus "while the Delete key is down".
More nonsense!
The other way to keep the two straight in your head is that events are things that KM is told about -- "The Delete key has been pressed down" -- while states are things that KM asks about -- "Is the Delete key still pressed down?".
I'm sure it's just me not understanding why the macro below works. It works even if in macos the repeat function is disabled. So if I press and hold "j" the cursor moves continuously to the left. On the other hand, if I change the trigger from "is down" to "is pressed", then the cursor moves only once.
With my limited logical capabilities, I assumed one could generalize this behavior.