it used to be considered a common and annoying problem to accidentally type a lot using a different language keyboard (e.g. have English keyboard on, but trying to type Russian in), that a lot of people had an automatic keyboard switcher installed for that case (I'm talking like, 20 years ago)
one popular app for that also contained a keylogger with your whole typing history
somehow i don't miss the switcher, but i miss the history sometimes. it surely would be a security nightmare, of course