I think it's because in windowed mode the game still has the focus until you click outside the window or alt-tab. So it's expected behavior for a Windows application. I understand how it can be annoying but not sure how to help you, maybe try full screen mode?