diff --git a/lib/src/index.js b/lib/src/index.js index 83fdfff..8b5c5b2 100644 --- a/lib/src/index.js +++ b/lib/src/index.js @@ -26,6 +26,7 @@ const MicroModal = (() => { openClass = 'is-open', disableScroll = false, disableFocus = false, + disableEsc = false, awaitCloseAnimation = false, awaitOpenAnimation = false, debugMode = false @@ -34,7 +35,7 @@ const MicroModal = (() => { this.modal = document.getElementById(targetModal) // Save a reference to the passed config - this.config = { debugMode, disableScroll, openTrigger, closeTrigger, openClass, onShow, onClose, awaitCloseAnimation, awaitOpenAnimation, disableFocus } + this.config = { debugMode, disableScroll, openTrigger, closeTrigger, openClass, onShow, onClose, awaitCloseAnimation, awaitOpenAnimation, disableFocus, disableEsc } // Register click events only if pre binding eventListeners if (triggers.length > 0) this.registerTriggers(...triggers) @@ -134,7 +135,9 @@ const MicroModal = (() => { } onKeydown (event) { - if (event.keyCode === 27) this.closeModal(event) // esc + if (!this.config.disableEsc) { + if (event.keyCode === 27) this.closeModal(event) // esc + } if (event.keyCode === 9) this.retainFocus(event) // tab }