What are different ways to use 'keyup' event within HTML?

120 views Asked by At

I have seen following 4 ways to use keyup event within HTML?

<input type="text" onkeyup="myFunction()">

<input #inputstring (keyup)="doSomething(inputstring.value)"/>

<input #inputstring (keyup.enter)="doSomething(inputstring.value)"/>

<input type="text" #formReplay (keyup)="0" />

I want to understand what is difference between the above three statements.

I have seen in angular a reference variable is created starting with #. I have seen bottom two approaches being used in angular.

<input #inputstring (keyup)="doSomething(inputstring.value)"/>

<input #inputstring (keyup.enter)="doSomething(inputstring.value)"/>

And, I have seen onkeyup used in plain javascript

I need some understanding on what are the various ways to use keyup in angular and in pure JS. Which one is a preferred way to use keyup?

0

There are 0 answers