Prevent toolbar popup from closing when pressing Esc

Hi, I have a working popup with a simple edit form input inside.

Something like: when click on edit item -> show form input. When the form is submitted, the updated item is shown.

I’ve added an event listener to the input, so when hitting the Esc key on the keyboard, the form will abort and the unchanged item is shown. This works - kind of - sadly the popup is closing immediately.

Is there any way to prevent the popup of closing in this case?
Even event.stopPropagation(); doesn’t work.

I don’t believe there is. Some keyboard shortcuts are deemed to important to be overwritable by content iirc.