Stop Modal Close on Escape Key Press

Hello I have progressive web app where i need to stop the modal close on escape key. I didn’t find any documentation to turn off this feature. Can somebody please tell me how can i achieve this?

I’m currently in this situation. Best thing I can think of right now:

  • Assign a class property to whatever the modal.onDidDismiss() returns
  • Do a null/undefined check, and run the same logic you would have done if the modal was dismissed with an intent to cancel the modal

from a UX standpoint, pressing the ESC key usually carries the intent of cancelling whatever process the user is in.

Its late, but I’m passing this on.

1 Like

Just disable the backdrop dismiss option

async showModal() {
const modal = await this.modalController.create({
component: ModalComponent,
backdropDismiss: false,
});
return await modal.present();
}

1 Like

@im-anzal Good answer, still works for Ionic V5.