Reproducible with inline and classic Editor.
Undo does not work the first time Ctrl + Z keys are pressed. It works, if you press them a second time.
If the keydown event handler is not attached, it works as expected.
Undo works on the first press of Ctrl + Z keys.