ng2-bootstrap-modal icon indicating copy to clipboard operation
ng2-bootstrap-modal copied to clipboard

Close with ESC (Escape) key

Open lexon0011 opened this issue 7 years ago • 4 comments

Is it possible to close the dialog with the ESC key (keyboard)

lexon0011 avatar Mar 22 '17 09:03 lexon0011

+1 for adding that option

philipp-serfling avatar Mar 29 '17 13:03 philipp-serfling

Please add this option , or tell me some workaround for this.

Prashant3108 avatar May 21 '17 19:05 Prashant3108

@Prashant3108

As a quick and dirty workaround solution you can add HostListener to your component.

Update the original confirm.component.ts example with the following

Import HostListener from angular core:

import { Component, HostListener } from '@angular/core';

Add @HostListener to your component Class:

export class ConfirmComponent extends DialogComponent<ConfirmModel, boolean> implements ConfirmModel {
....
....
....
    @HostListener('document:keyup', ['$event']) handleKeyUp(event) {
        if (event.keyCode === 27) {
            this.close();
        }
    }
}

villepie avatar May 27 '17 23:05 villepie

Is it possible to make it in a specific component of my project for example in a single modal?

pjunior94 avatar Dec 04 '17 17:12 pjunior94