Angular Input Keypress Event Example

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

I am going to show you example of angular input keypress event example. i explained simply about angular textbox keypress event example. here we will see simple example of input box keypress event angular. you can understand a concept of angular input change event on keypress event. follow bellow step for keypress event in angular.

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

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

<input type="text" (keypress)="onKeypressEvent($event)" />

onKeypressEvent(event: any){



Let's see full examples now:



<h1>Angular Textbox Keypress Event Example -</h1>

<input type="text" (keypress)="onKeypressEvent($event)" />


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


selector: 'my-app',

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

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


export class AppComponent {

name = 'Angular ' + VERSION.major;

onKeypressEvent(event: any){




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: