keyDownEditor needs to be set only if the key is going to generate a character in the page. So we only have it set for keypress events and keydown events for enter and tab keys.

I can move the code to the top of handleKeyEvent as you said for simplicity reason, but I don't think it is right even though I don't have a proof for a case this can go wrong. By moving to the top we're setting the keyDownEditor even when a modifier key is pressed and also for all key up events. So let me know if you still insist on setting it for all key events.