Fixes #16573.  Check for key event type before checking other key event attributes.