Hi Niel,
Damn, you're observant. Of course, I was hoping you wouldn't see this.
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.
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.
Thanks noisneil 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.
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.