This is theoretically pretty extensible, but you need an OS-wide keylogger. On the Linux side, I'm not sure if Wayland allows for that at all.