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

130
Views
usando la tecla Shift + Enter para ejecutar una función

Soy un poco nuevo en JS, he buscado en Internet y no tengo lo que estoy buscando, quiero ejecutar una función si se presionaron las teclas Shift y Enter, como un atajo, he intentado esto pero creo que maté a JS con este código

 document.addEventListener('keypress', function (e) { if (e.key === 'Enter' + 'Shift') { console.log("test"); } });

cualquier cosa seria de ayuda, gracias.

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

0

Puede usar e.shiftKey para ver si se está presionando shift.

 document.addEventListener('keypress', function(e) { if (e.key === 'Enter' && e.shiftKey) { console.log("test"); } });

about 4 years ago · Juan Pablo Isaza Report

0

Esta es una solución bastante ampliable porque puede crear accesos directos para muchas teclas diferentes.

 const keysDown = {}; document.addEventListener('keydown', ({ key }) => { keysDown[key] = true; if (keysDown.Shift && keysDown.Enter) console.log("test"); }); document.addEventListener('keyup', ({ key }) => { keysDown[key] = false; });

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!