How do I setup keyboard macros?

I did some googling and found a program called AutoKey (Autokey - Linux utility for text substitution hotkeys) near the top of the list.

Rather than a hotkey using Ctrl+Shift+K I chose to assign the abbreviation kz which is automatically expanded into <kbd></kbd>+.

It is simply installed using:

sudo apt install autokey-gtk

It installs in Launcher and the screen is pretty simple to use:

Autokey


What also can be done is to use xdotool withtype flag, like so:

bash -c ' sleep 0.5; xdotool getactivewindow  type "<kbd></kbd>"'

Go to System Settings-> Keyboard-> Shortcuts -> Custom and bind that command to whatever keyboard shortcut you want. I chose CtrlSuperK. What happens here is that we give user delay of 0.5 seconds to release keyboard shortcut, and then xdotool will type out the key markup tags just as if you were doing it yourself on keyboard. Very easy and simple approach. In fact I am used it just now to put in those 3 keys above.

Note that xdotool doesn't come with Ubuntu by default, so you will have to install it via sudo apt-get install xdotool