Skip to content

Instantly share code, notes, and snippets.

View faisalahmedador's full-sized avatar

Faisal Ahmed faisalahmedador

View GitHub Profile
import {Directive, OnInit, HostListener, Output, EventEmitter} from "@angular/core";
@Directive({
selector: '[capsLockDetect]'
})
export class CapsLockDetectDirective implements OnInit{
@Output() capsLockOn = new EventEmitter<number>();
capslock:number = 0;
constructor(){}
<div class="form-group">
<input id="password" capsLockDetect (capsLockOn)="capsLock = $event" type="password">
<small class="form-text text-muted">Password</small >
<strong class="capslock-warning" title="Caps-lock is ON!" *ngIf="capsLock === 1">
Caps-lock is ON!
</strong>
</div>