Answer the question
In order to leave comments, you need to log in
How to cancel the standard action on ESC in Safari?
When using Safari in full screen mode and pressing the "Esc" key, the full screen mode is first exited and only when pressed again, the standard keyup event fires. How can this be overcome?
For an example on the modal https://codepen.io/DmitrySheklein/pen/VwWNYoj
Auto.ru somehow managed to do this (if you open and close the carousel of a car photo), but I did not find a fix for this problem in the code.
https://auto.ru/review/cars/toyota/verso/8507941/8...
macOS Big Sur 11.6
Answer the question
In order to leave comments, you need to log in
document.onkeydown = function (evt) {
if (evt.keyCode == 27) evt.preventDefault();
document.querySelector('.modal').classList.remove('show')
}
const handleEscClose = evt => {
if (evt.keyCode == 27) {
evt.preventDefault();
document.querySelector('.modal').classList.remove('show')
}
};
document.addEventListener('keydown', handleEscClose);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question