Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

466
Views
Angular: ¿cómo activar eventos de teclado al hacer clic en un botón?

He proporcionado dos botones separados para Ctrl+z y Ctrl+y. Quiero que la funcionalidad Ctrl+z y Ctrl+y se realice con el clic de un botón. Aquí está mi función.

 undoText(event:MouseEvent){ var element = document.getElementById("undoBt") if(element){ element.dispatchEvent(new KeyboardEvent('keydown',{composed: true, bubbles:true, cancelable:true, code:"ControlLeft", ctrlKey:true, key:'Control',keyCode:17, location:1})); element.dispatchEvent(new KeyboardEvent('keydown',{bubbles:true, cancelable:true, code:"KeyZ", composed:true, ctrlKey:true, key:'z', keyCode: 90})); } }

Aquí está mi html.

 <mat-icon matTooltip="Undo" (click)="undoText($event)" *ngIf="svgInit" id="btn1" class="undo" svgIcon="undo" aria-hidden="false" aria-label="undo"> </mat-icon>

Para lograr esto, intento activar Ctrl+z y Ctrl+y al hacer clic en el botón, pero no se activan y no puedo establecer la propiedad isTrusted como verdadera.

¿Qué está mal con el código?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

(keyup.enter)="keyUpFunction($event)"

Donde keyUpFunction($event) es su función.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!