It's not clear why keyDownEditor is set in some conditions but not others in handleKeyEvent. I think this might lead to some cases that don't work and it will be harder to maintain. What if keyDownEditor is set at the top of handleKeyEvent instead of only in certain conditions? It seems simpler. I tried that in a local copy of your branch and it seems to still fix #2620 (but #2621 is still broken).