Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Avoid modal close when ESC key is pressed

sergiojaviercaz premium asked 2 years 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 2 years 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