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

144
Views
Cómo enviar KeyboardEvents a un elemento de entrada

Estoy tratando de enviar KeyboardEvents a un elemento de entrada en una prueba basada en JSDOM. Pero en aras de la simplicidad, aquí hay un ejemplo de página web. De acuerdo con cada muestra, publicación de blog o tutorial que puedo encontrar, parece que esto debería funcionar. Pero no es así.

¿Qué más necesito?

 <html> <head> <title>Keyboard Event Conundrum</title> <script type="text/javascript"> window.onload = function() { var textField = document.getElementById("text-input"); var button = document.getElementById("the-button"); textField.value = "This works! "; button.addEventListener("click", function(event) { textField.value = ""; textField.focus(); // expected to add 'a' to the input's value, but doesn't var keyEvent = ekp = new KeyboardEvent("keypress", { altKey: false, bubbles: true, code: "KeyA", ctrlKey: false, key: "a", metaKey: false, shiftKey: false }); textField.dispatchEvent(keyEvent); }, false); } </script> </head> <body> <div> <input type="text" id="text-input" /> <button id="the-button" type="button">send keyboard event</button> </div> </body> </html>
about 4 years ago · Juan Pablo Isaza
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!