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

157
Views
detectar arriba/abajo y teclas de tabulación presionar en JavaScript

¿Cómo puedo detectar si se presiona la tecla up/down/left/right o la tecla de tab ? Traté de usar el código a continuación, pero no imprime nada cuando se presionan esas teclas

 document.addEventListener('keypress', (e) => {
 console.log(e.key)
})
almost 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Necesitas usar keydown en lugar de keypress

 document.addEventListener("DOMContentLoaded", function(event) {
 document.addEventListener('keydown', (e) => {
 console.log(e.keyCode)
 })
})

almost 4 years ago · Santiago Trujillo Report

0

document.onkeydown = checkKey;

function checkKey(e) {

 e = e || window.event;

 if (e.keyCode == '38') {
 console.log("up arrow")// up arrow
 }
 else if (e.keyCode == '40') {
 console.log("down arrow")// down arrow
 }
 else if (e.keyCode == '9') {
 console.log("tab")// tab
 }
 

}
almost 4 years ago · Santiago Trujillo 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!