Reset special keys in case of window switching. Fixes issue #226. Fixes issue #268.