I use two different keyboard inputs qwerty and dvorak.
I want to have qwerty as my main input (since all shortcuts works best that way), but when I have text field in focus I want my input to change to dvorak. Right now I jump a lot between them. I know how to set up the macro. But I cant find a trigger that work the way I want.
I just did a quick look on my computer and by showing the Input Menu, both Qwerty and Dvorak choices are there. Seems to me you could use a KM "If" action to see which is active and have it switch to the other.
This isn't exactly the answer to the question you asked, but are you aware of the Dvorak - QWERTY ⌘ keyboard layout? It reverts the layout to QWERTY whenever you hold down Command to preserve shortcut muscle memory for just this sort of use case: Use Dvorak keyboard layouts on Mac - Apple Support