iMessage (Messages) text entry has space in it

I am using Keyboard Maestro 6.4.8 and in Monterey (and Big Sur before) when entering text and using a Macro for text entering, it enters the text but also a space before it.

This only happens in Messages app.

Howdy, welcome to the forum! As you might have already figured out, this is a great community full of people who love to help.

If possible, post the macro itself so we can take a look at it and see what might be going wrong. As one of the moderators likes to say, "If we're not testing we're guessing, and guessing often wastes people's valuable time". :laughing: If you need help on how to post the macro, just let us know and we can walk you through it.

If you haven’t had the opportunity to read this tutorial, I highly recommend it. It will help you get the most help for your question.

Tip: How Do I Get The Best Answer in the Shortest Time?

On another note however, I have noticed that Messages also has a weird issue with Typinator expansions that are not present in other apps. When using RegEx to expand text it creates an extra space behind the expanded text. This might be simply an error with my RegEx formular however. So being able to see your macro would help a lot.

Also, any reason in particular you're using such an old version of KM? :grin:


Ć.kmmacros (1.3 KB)
Thanks for the tutorial.

Old version - sufficient for my needs (only use it for a couple of letters, similar to the one added here).

I use Dvorak keyboard layout, which is great but does not have cyrillic letters, which i can use with KM Macros.

I see what you're saying... for me (setting my keyboard to DVORAK and triggering the macro in Messages) if it's not following another character it works fine, but if it's following another character it has a space...

However I changed the action to insert by typing and it works fine. Might try it that way.

Hm, tried it that way but then it won't enter anything (Messages or in any other place for that keyboard combo).
Here the updated macro
Ć.kmmacros (1.3 KB)

without having time right now to look at the new macro I'd say you might need double-check your trigger. I'll try and take a look at it tomorrow though :+1:t2:

EDIT Monday, January 24, 2022 @ 08:14:52 AM: @MaestroOfKey so I just tried it and can confirm that it doesn’t work I Messages (or Notes for that matter) with that trigger and insert by typing (but insert by pasting does work). I tried a couple of hotkey triggers and they also didn't work with insert by typing. I don't really know why but I imagine it has something to do with the alternate keyboard layout. Hopefully others will chime in too with more knowledge on this.

Just to add - upgraded now to the newest version (11.0.1).
Still the same problem with iMessage adding a space when entering a KM Macro.
macOS newest as well (14.1.1).

Any ideas how to solve it?

I'm observing a similar problem, but not identical. I'm going to guess that your "Keyboard Type" is different from mine.

Just for debugging purposes, are you willing to try changing your keyboard type to a standard US keyboard to see if the problem with your current macro persists?

At this point my lead suspect is the KM Insert Text action which may have an issue with inserting keys by typing if the keyboard type is unusual.

Yes, I am using a different keyboard type (Dvorak).
Switched now to U.S. (and to be sure, also tested with US International PC).
Screenshot 2023-12-03 at 12.52.11

It behaves the same, see screenshot
(all letters typed without a space, however the macro one's have a space added before the typed letter).
So far this behavior I have only encounterd on iMessage.

Okay, so my idea wasn't correct. I have one more idea. MacOS has something called "predictive typing" which interferes with keystrokes by replacing or adding keystrokes as it deems necessary. Are you willing to go to the System Settings and turn off all 6 switches to test? It will take you only a minute to test, but has a chance of being the underlying cause.

In the System Preferences window, in the search box, type "spelling" and press Return. Then click on "Spelling and prediction."

Messages does not seem to like having the Control key pressed while typing the characters.

If you add Pause Until action with a Modifiers condition to the front of the macro:


Then it works correctly for me.

Without that Messages will not accept the typed Ć. I don't know why.

That's an elegant simple fix along with an elegant diagnosis.

I tried your solution, but now I have it even worse:

  • it still adds a space to the letter
  • I have to release the button to see the letter (which is not optimal, since you expect to see the letter when you press it, not when you release it)

Did I set it up correctly?

When Messages sees the pasted Ć, it pastes it as a word. This appears to happen regardless, even if I just paste it in manually.

Keyboard Maestro can type the character (at least with my keyboard layout), but that will not work if the control key is down in Messages. So this works for me in Messages:

Note both the Pause Until and the Insert Text by Typing.

1 Like

Fantastic, it works, thank you very much. :pray:

Will have to get used to the fact that the letter shows up only after keystroke release, but I guess with time it will entere my muscle memory.

1 Like