Prevent closing of Angular Material Dialog when escape button is pressed but allow closing when backdrop is clicked
By default, when the esc button is pressed, the dialog closes. However, I don't want this intended behaviour. What I would like to happen is to prevent closing when the esc button is pressed but still allow a click on the backdrop to close the dialog. How can this be done? I've tried something like this. However, it doesn't work: openEditDialog() { const dialogRef = this.dialog.open(EditPlaceDialogComponent, { width: '90%', height: '720px' }); dialogRef.keydownEvents().subscribe(e => { if (e.keyCode === 27) { e.preventDefault(); dialogRef.disableClose = false; } }); dialogRef.afterClosed()