How do you transform text with just one key?

What I do in the video (below, compressed) is the following::

  • I have written some text (not bold).
  • The cursor is at the end of the text.
  • Then I press and hold “j”.
  • Now every word to the left of the cursor is (slowly) selected.
  • When I release “j,” the selected text becomes bold, “j” is deleted, and the cursor returns to where it was.

This should not interfere with normal typing. “j” should be typed like any other letter.

Can this be done with KM? And if so, can someone show me how? Thank you very much!

Bold text.zip (100.7 KB)

What's the 11th Commandment, Frank? :joy:

The macro is certainly doable, but let's not get into single character hotkeys, eh?

1 Like

Hi Niel,
Damn, you're observant. Of course, I was hoping you wouldn't see this.:rofl:
Think about string triggers — they shouldn't really exist. But as long as you only use them in text fields, they can be very useful.

Mmm, let's do it anyway, do it for me. For a lost soul who always does what one shouldn't. :smirking_face:

Edit: Of course, I thought of your brilliant macro. But unfortunately, it doesn't work because a letter (short pressed) is typed when the key is released. However, your macro (long pressed) works when a key is pressed, which is perfect.

The question is: Can KM perform two actions when a key is pressed, one immediately and one a little later, but only if the key remains pressed?

Pressing and holding 'j', and wanting to check the condition of that key every single time the macro loops through, is going to make for a slow and painful macro, and one potentially fraught with timing errors.

If I were wanting to do something like this, well, I wouldn't use a single-key trigger :). But If I absolutely had to, I would use it as a marker: Press 'b' to denote the start of the bold, move the cursor to where you want the bold to end, press 'b' again. The macro then does the actual work of bolding the text.

But honestly, I still wouldn't do it that way. If I wanted to use a single key, I'd use a single modifier key, because that's not sent to any app. And that's exactly what I did when I wrote something similar, my Universal Highlighter macro, which uses the Highlight feature in 10+ apps to let you quickly highlight text, continuously, by just selecting chunks of text.

You launch it with a modifier key double-tap, then it keeps running until you tap any modifier key once. While running, as you select text, it's highlighted as soon as you release the mouse button.

You could use a structure like this (which requires three "Until" loops to track keys and the mouse) to bold instead of highlight. And if it was just for one particular app, it could be a lot simpler—mine kept expanding to cover more and more apps that offer highlighting.

-rob.

Agreed. You could also use a character key that you'll never type (in that app).

My globally available, per-app Trigger Macro by Name key is § and my app-specific, per-app special function key is `, for exactly this reason.

Embolden the Left.kmmacros (42 KB)

Macro screenshot

Thanks noisneil :slightly_smiling_face: that works exactly as I want it to. However, you lose the actual function of the key used, e.g. “j”. The “workaround” would be to use cmd + j, for example. The conversion would take place as soon as “j” is released. That works very well with your macro.

Do you see a way that “j” is always typed and deleted after the conversion?

I'm not sure I understand. Actually, that's exactly what shouldn't be done. The macro is only executed in a text field. So the letter should always be typed immediately and the selection function should take place later.

Your highlighter macro is great, but I want to do everything without the mouse.

And unfortunately, I didn't understand this :slightly_frowning_face:

Sorry, I missed that requirement. I thought you were trying to mark up existing text.

-rob.

All good :slightly_smiling_face: , could you explain to me how this “marker” works?

I don't follow. If you use ⌘J, j won't be typed.

Yes :slightly_smiling_face: , but we're back to the sin of single key triggers. I mean, if I only want to use “j”.

So don't? :man_shrugging:t2:

It doesn't really apply to your situation—it was for working with an existing bunch of text onscreen, not in an input block. And it involved the mouse, not the keyboard.

-rob.

Okay, thanks anyway, both of you.

Just so that I am sure: KM can't perform two actions in succession with a single key (on key down). Correct?

If you change the trigger and condition in the macro I gave you above to J, it'll work exactly the same way (although I wouldn't recommend it).

Perhaps we are misunderstanding each other. The macro below never simply types “j”.

...is what you actually asked.

If you want it to type j, add a simulated j keypress to the macro, wherever you want it to happen.

Sorry, my knowledge is more than modest. You mean like this? That doesn't work.

Works for me:

CleanShot 2025-10-10 at 23.12.48

What happens when you type “j” and then another letter?

CleanShot 2025-10-10 at 23.19.55

(I realise it should either be "jelly donuts" or "jam doughnuts". Don't @ me :zany_face:)