I have a modal which I want to close when user pressed the Escape
key.
However, this modal also contains form fields that may benefit from default behaviours from the browsers.
For exemple an opened <select>
element will close when hitting the Escape
key.
If this happens I don't want to close the modal since I consider the user wanted to close the <select>
when hitting Escape
. However, when it is already closed, I want the modal to close.
The question is: Is there a way to know whether a default event was fired or not?
It seems the defaultPrevented
property is called whenever preventDefault()
was, whether or not it actually prevented something.