You know when you are sitting at your computer typing away, sometimes the window focus changes, a pop-up appears or a program starts and you lose focus on the window where you were typing.
Usually what happens is that whatever you are typing at the moment of the focus change gets lost. But where does it go?
When a window has focus and you type, that window receives keypress messages. When another window steals focus, the latter window starts receiving those messages instead. If that new window rejects or ignores those messages, that’s when the keystrokes “disappear”.