Apparently X11 has a security extension [1]. There was a discussion some months ago [2].
Xenocara (X on OpenBSD) improves security by dropping privileges and using features like pledge [3], but I don't know how this affects the feasability of keyloggers.