Answering this very question using Tridactyl for Firefox.
It's not OS-wide but I spend so much time switching from browser to terminal, it might as well be.
https://tridactyl.xyz/build/static/docs/modules/_src_excmds_.html
Also for the keyboard itself I use a Corne-ish Zen, which allows me to use ZMK and thus have my own keymap https://github.com/Utopiah/zmk-config-zen-2/blob/main/config/corneish_zen.keymap
I use KDE which with Super+T brings up tiling options.
Regarding the "API" aspect, a trick I used few times to be able to remote control a desktop in VR is xdotool
but it's honestly quite tedious. Without some accessibility solution implemented in apps themselves, I doubt it's reliable.