Autokey- set a shortcut to apply only in text/input fields

I am using Autokey in Ubuntu 18.04 LTS to emulate the text editing keybindings on MacOS e.g. ctrl+left to go to start of line, shift+ctrl+right to highlight to end of line etc. These are what come naturally to me, and make a lot more sense than having to apply the fn key on my keyboard to use home and end (fn+shift locks fn so highlighting can be inconsistent). I am also switching between using a Macbook and a Linux machine (HP Elitebook), so want to keep the bindings as similar as possible.

The phrases are working very well, in fact, too well! They are activated in all contexts, and there are times when a combination like ctrl+right is used for something else i.e. to ‘go back’ in a browser, or to switch through applications in the application switcher. At the moment these do not work, and I get either top of page (in Chrome) or the bump error noise (in application switcher).

What I would like to do, is have Autokey only apply the custom shortcut when I am in a text/input field, and leave the other functionalities to work otherwise. Is there some kind of regex/class filter that can apply the shortcut to all applications, but only in some context?

(I am very unfamiliar with regex so maybe there is a simple solution that I do not know about).

AutoKey question: How can I hold down a simulated keypress while holding down the key combination?

My laptop’s Escape key recently got broken so I temporarily mapped it to Super + X using AutoKey via keyboard.fake_keypress("<escape>"). However, I found that this doesn’t hold down the Escape button but instead presses it once only. How do I script it to where as long as I’m holding down the key combination Super + X, the Escape button is also simulated held down. When I release, it also gets simulated released.