And it doesn't matter whether you're using X11 or wayland if someone is sniffing your keyboard over the air with an SDR.
umatechnology.org
Or if they have physical access to the machine... I'm sure smaller ones than this are available. Or the whole cable is replaced and has the logger built in. Or the logger has been placed inside the keyboard. If in doubt, use brute force.
Millions Of Wireless Keyboards Can Be Hacked By Radio Hack, Keystrokes Can Be Stolen - UMA Technology
Wireless Keyboards Vulnerable to Radio Hack Attacks

Or if they have physical access to the machine... I'm sure smaller ones than this are available. Or the whole cable is replaced and has the logger built in. Or the logger has been placed inside the keyboard. If in doubt, use brute force.