Skip to content
Angular 4+ Directive adding event for escape key
TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.editorconfig
.gitignore
LICENSE
README.md
package-lock.json
package.json
tsconfig.json
tslint.json

README.md

angular-esc

Angular 4+ Directive adding (esc) event for escape key press.

Installation

  1. Get it from npmjs (for npm <v5 add --save flag):
npm i angular-esc
  1. Import EscModule into your application:
import { EscModule } from 'angular-esc';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, EscModule],
  bootstrap: [AppComponent]
})
class AppModule {}

Usage

@Component({
  selector: 'app',
  template: `
    <div *ngIf="isVisible" (esc)="isVisible = false">I will hide after Escape is pressed</div>
  `
})
export class AppComponent {
  public isVisible: boolean = true;
}

Options

Property name Type Default Description
watchEsc boolean true false value will disable the watcher
stopEscPropagation boolean true By default the event is not propagated further, you can change it here.
You can’t perform that action at this time.