This particular macro doesn't deal with lists, tables or other complex formatting. If you need that sort of thing, you're better off with this excellent macro by @_jims.
For a comprehensive guide to text formatting, you may also like to check out another of his posts.
Usage:
Select some text, trigger this macro, choose a style and either click it or hit ↵.
The Copy action does exactly what the Copy and Wait for Clipboard to Change group does.
And Insert Text by Pasting action does exactly what the last two actions (Set System Clipboard to Text (oddly renamed to Set System Clipboard to Style Text) and Paste) do.
It makes no difference of course, you can use multiple actions to do what a single action does with negligible cost.
If I have text selected and trigger the macro, but then discover that I need to do something else before applying a style, it would be nice if the window could be dismissed two ways: 1) esc, or 2) return (with nothing in the Search formats... field).
Admittedly I'll probably use the search, enter a few characters, and return method mostly, but when using the click method, I'd prefer a single click vs a double click.
When no text is selected and the macro is triggered, IMO it's a bit disconcerting when nothing happens. Consider falling back to the clipboard text. This is really nice when pulling text from one doc for another. If this piques your interest, check out: Get Selected Text, Otherwise Clipboard
Consider adding an option to apply the <kbd> tag to the string as a whole.
Lastly, you mentioned Augment or Transform Text. I do use it often when composing forum posts, but I probably use it more when creating macros. Just an FYI for those that might want to check it out.
Thanks for the suggestion. I added this in haste late last night when I noticed the potential for the macro to continue perpetually if no text has been selected, but forgot that the Copy action has its own timeout (not all actions do). I've updated it now, with an added check to ensure the clipboard contains text.
I know, yeah. This is the result of me considering things I could do with the clipboard other than just paste it. Updated now.
It's a habit of mine to name actions so that I know exactly what they're doing without having to expand them. Moot now that I've removed it.
While I have your attention... In lieu of a solution to the rather aggravating scroll behaviour of extended text boxes, do you think you might be able to implement a search box for script actions so that we can quickly find things that need editing?
Good call. I've also added it to the original post.
Great suggestion. Done.
Yup. Done.
Great minds think alike. I disabled Timeout Aborts Macro in the Copy action when going through Peter's suggestions, which seems to have taken care of it quite neatly.
Done!
Thanks for pointing that out. I'll adjust the wording of the post to make it less Forum-centric.
Here's a tip for users of PopClip who wish to trigger your macro using PopClip. It's very easy to do and here's how my PopClip tool looks (highlighted with the red box) after I've configured it to run your macro:
PopClip works by popping up that little menu whenever you select something. In this example I've selected the text Here's a tip for users and immediately up pops the PopClip menu, the first item being your macro. You can see some other items in the menu such as Typinator and other basic actions. Clicking on that menu item then brings up your macro with whatever has been selected.
To install your macro into PopClip you just need to select the following text and when PopClip appears choose the Install Extension "KMStyle" and that's it!