В показанном модале есть форма. Если я сосредоточусь на поле ввода (любое поле в этом отношении) и нажмите клавишу ESC, этот модал будет скрыт. Однако, если я не фокусируюсь на поле формы, то нажатие клавиши ESC не закрывает модальное. Что происходит?
Я хочу отключить функциональность клавиш ESC для всех моделей. Я пробовал это:
$(document).on('keypress', function(e) {
if(e.keyCode == 27) {
e.preventDefault();
return false;
}
}
Но это ничего не влияет. Есть ли способ полностью отключить клавишу ESC для модалов?