Malware and other applications may install persistent keyboard “event taps” to intercept your keystrokes.

https://objective-see.com/products/reikey.html