Topic: Avoid modal close when ESC key is pressed

sergiojaviercaz premium asked 1 year ago

Is there a way to avoid the modal closing when ESC key is pressed ? I tried trapping the keydown event and using preventDefault but it seems not to take that in consideration and the modal closes anyway.

Mateusz Lazaru staff answered 1 year ago

We've provided an keyboard option to do that. Code you're looking for: data-mdb-keyboard='false'

Check out my snippet:

All modal options are described here:

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Premium
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 6.0.1
  • Device: PC
  • Browser: Chrome
  • OS: W11
  • Provided sample code: No
  • Provided link: No