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:

https://mdbootstrap.com/snippets/standard/mlazaru/4767753

All modal options are described here: https://mdbootstrap.com/docs/standard/components/modal/#api-section-options



Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Answered

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