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

129
Views
El evento KeyPress se compila como un evento Key Down

Quiero que cuando presione cualquier tecla del teclado, cada carácter en el elemento "matriz" se escriba en el elemento "registro" uno por uno. el problema es que cuando mantengo presionado el botón del teclado el código sigue escribiendo en el elemento "log".

 window.onload = () => { let log = document.getElementById("log"); } let string = `CODE EXAMPLE : let firstName = "user"; let lastName = "userLastName" let Bool = |true;| if (Bool === 1) { console.log(firstName += lastName); }`; let array = string.split("|"); let i = 0; let x = 0; log.addEventListener("click", () => { document.addEventListener("keypress", type); }) function type() { log.innerText += array[i].charAt(x); x++; if (x === array[i].length) { x = 0; i++; } if (array[i] === undefined) { document.removeEventListener("keypress", type); } }
 #log { height: 350px; width: 500px; padding: 15px; position: absolute; left: 10px; color: rgb(0, 255, 0); font-size: 14px; background-color: rgba(0, 0, 0, 0.7); border-radius: 25px; white-space: pre-wrap; line-height: 20px; } #log::after { content: ""; position: absolute; width: 7px; height: 20px; background-color: rgb(0, 255, 0); animation: animation .5s infinite linear alternate; } @keyframes animation { to {background-color: transparent;} }
 <pre id="log"></pre>

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!