Create virtual key up events for all pressed keys when the display loses focus.

This is a workaround for missed key events and incorrect key state reporting. This is actually a cleaner solution to the previous workaround on Windows and works nicely on Linux too.