iMacs unexpectedly typing foreign characters
For a little over six months now I've been having issues with my Macs. It started on my 2019 Intel iMac 27" when I would get glitches in Photoshop and if I typed anything (for example to Google something in Safari) I would get foreign characters instead of the Roman alphabet. Restarting sometimes worked as did shutting down and resetting the SMC or PRAM. I cleaned my keyboard since the explanation I found online was likely a stuck option key.
Eventually, as my machine was getting older anyway, I decided to get a new iMac (2024 M4 24") but the same thing started happening again though less frequently. For a while now I've had the accessibility keyboard permanently open on my desktop so that I can see when the issue has happened. The attached image is what I get (I'm not touching any keys at the time). Can anybody explain what is happening and how I can resolve it?
iMac 24″, macOS 15.7