Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
keyup, keydown, blur are not working in angular 12

I am using angular 12 and trying to play with events. The only click event is working, no other events are getting triggered.

allEvents.ts

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

@Component({
  selector: 'app-all-events',
  templateUrl: './all-events.component.html',
  styleUrls: ['./all-events.component.css']
})
export class AllEventsComponent implements OnInit {
  constructor() { }
  ngOnInit(): void {
  }
  myEvent(evt : any) {
    console.error(evt)
  };
 
}

allEvents.html


<button (click)="myEvent('I am click event')" >Click Event</button>
<br><br>
<input type="text" (onkey)="myEvent($event)" />

When I click on the button on console statements are getting executed, but keydown, keyup, or blur is not working.

-----Configurations------

Angular CLI: 12.2.12 Node: 14.17.6 Package Manager: npm 6.14.15 MACOS: darwin x64

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This list contains all of the events supported by angular and their syntax:

(click)="myFunction()"      
(dblclick)="myFunction()"   

(submit)="myFunction()"

(blur)="myFunction()"  
(focus)="myFunction()" 

(scroll)="myFunction()"

(cut)="myFunction()"
(copy)="myFunction()"
(paste)="myFunction()"

(keyup)="myFunction()"
(keypress)="myFunction()"
(keydown)="myFunction()"

(mouseup)="myFunction()"
(mousedown)="myFunction()"
(mouseenter)="myFunction()"

(drag)="myFunction()"
(drop)="myFunction()"
(dragover)="myFunction()"

As you can see the onkey event doesn't exist and you should implement your logic with keyup, keydown or keypress(guess you want to use is this)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda