Write a macro which toggles a character style?

If you go Ctrl-B you toggle on the Bold attribute. If you then go Ctrl-B you toggle it off again.

Is there any way of doing this with a character style of your own devising? I have created a style called “commentary” and then assigned Alt-D as a shortcut for it.

I have also set a shortcut for the “Character Default Style” (Alt-Shift-0). So a sort of workaround is to go Alt-D… write something… and then go Alt-Shift-0.

But this is not a toggle (i.e. using the same hotkey to switch on and off). And supposing the character style is some other character style than “Character Default Style” when I start writing “commentary”?

The Ctrl B is not a toggle either: it just apply direct formatting twice and can create a lot of formatting trouble in your document. To erase direct formatting you should use Ctrl M and to erase a character style you can only use, as you found, the default character style.

@RGB-es rather insightful. thank you for the info.