Angular Input Keydown Event Example

By Hardik Savani | May 8, 2020 | Category : Angular


This post will give you example of angular input keydown event example. This tutorial will give you simple example of angular textbox keydown event example. this example will help you input box keydown event angular. We will look at example of angular input change event on keydown event. You just need to some step to done keydown event in angular.

In this post i will show you very simple example of onkeydown event in angular. you can easily use keydown event in angular 6, angular 7, angular 8, angular 9, angular 10 and angular 11 application.

When user will key up on input box field then trigger onKeyDownEvent() of angular component. we will use (change) attribute for call function. let's see bellow logic code.

<input type="text" (keydown)="onKeyDownEvent($event)" />

onKeyDownEvent(event: any){

console.log(event.target.value);

}

Let's see full examples now:

Example

src/app/app.component.html

<h1>Angular Textbox Keydown Event Example - ItSolutionStuff.com</h1>

<input type="text" (keydown)="onKeyDownEvent($event)" />

src/app/app.component.ts

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

@Component({

selector: 'my-app',

templateUrl: './app.component.html',

styleUrls: [ './app.component.css' ]

})

export class AppComponent {

name = 'Angular ' + VERSION.major;

onKeyDownEvent(event: any){

console.log(event.target.value);

}

}

I hope it can help you...




Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: