While the other answers handle this specific situation nicely, there's a way to do things like this and a lot more with almost any application or set of actions.
AutoKey allows you to write scripts that emit keyboard and mouse events to perform most tasks you could do manually with your keyboard and mouse. Most applications can't tell it's not you typing and clicking, so they can be controlled even if they don't have any provision such as an API.
AutoKey scripts are written in Python 3, so they can do almost anything. An API is provided to generate keyboard and mouse events and for some desktop/window manager interactions.
A script can be assigned a hotkey so that it runs whenever that hotkey combination is pressed. Window filters can also be defined so a hotkey only triggers a particular script if the current active window matches its filter. Otherwise, the hotkey is passed to the application.
AutoKey also provides phrases. These are like a very powerful autotype/autocorrect feature.
Phrases and scripts can be triggered by hotkeys or run when a specified trigger abbreviation is typed. There are a number of options to fine tune how this works.
AutoKey scripts for most common uses can be written with a very minimal knowledge of Python. You don't need to know most of the language. However, if you do know more, you can easily put it to use.
The current version of AutoKey is available in the Debian repositories used by Ubuntu since 20.04, so you can install it with your package manager.
The project is active and a new beta release is being tested.
For more information, see our wiki and our support forum or our Gitter page.