@mhoye
KDE has some settings to tune how/when windows get focused [1]. I don't think there's an (easy) way to make it depend on whether you're typing, but maybe you can get close to what you want with "Focus follows mouse" and potentially messing with "Focus stealing prevention".
(It's a bit more complicated than one might like, with the two separate settings, each with somewhat unclear descriptions...)
I personally don't recall accidentally doing something in a window that stole my focus, but when I tried spawning a full screen terminal on a timer it did end up stealing focus & keyboard input with my settings, so maybe I've just been lucky so far.
https://docs.kde.org/trunk_kf6/en/kwin/kcontrol/windowbehaviour/index.html
@noodle @Kuniti_shino