Key event ordering bugfix