1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-26 06:44:35 +02:00

Replace event.which with event.key and event.button

This commit is contained in:
Tanguy Krotoff
2020-04-15 16:52:18 +02:00
committed by XhmikosR
parent 8547ab149a
commit dcd99aa7d1
7 changed files with 100 additions and 110 deletions

View File

@@ -31,7 +31,7 @@ const VERSION = '4.3.1'
const DATA_KEY = 'bs.modal'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
const ESCAPE_KEYCODE = 27 // KeyboardEvent.which value for Escape (Esc) key
const ESCAPE_KEY = 'Escape'
const Default = {
backdrop: true,
@@ -299,10 +299,10 @@ class Modal {
_setEscapeEvent() {
if (this._isShown) {
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
if (this._config.keyboard && event.which === ESCAPE_KEYCODE) {
if (this._config.keyboard && event.key === ESCAPE_KEY) {
event.preventDefault()
this.hide()
} else if (!this._config.keyboard && event.which === ESCAPE_KEYCODE) {
} else if (!this._config.keyboard && event.key === ESCAPE_KEY) {
this._triggerBackdropTransition()
}
})