Way to prevent shortcuts from triggering while text field is in focus?

I've got a custom key palette on Ableton that I've made that causes certain keystrokes to be replaced by others. When I am renaming a track, or doing something text-based, I'd like those shortcuts not to activate. On a side note, the command palette is still active when I open Mac's spotlight, which I also don't like, because it messes up Spotlight's input.

So in short, is there any way to prevent command palette shortcuts from engaging whilst a text field is in focus?

Not generally. There is no reliable general way to determine if the current focus is a text field.