every time I press and hold a key my mac freezes
Every time I press and hold a key, my system freezes, it does not respond and the screen does not update, I have disabled ApplePressAndHold in defaults, but the problem has been occurring before I did that. I can press and hold keys like shift, fn, control option and command. I am using the stock iMac magic keyboard 2. The problem occurs both when I connect the keyboard via bluetooth and via USB.
iMac 21.5" 4K, macOS 10.14