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

201
Views
Javascript: bucle hasta que se presiona CTRL+C

¿Cómo puedo hacer un fragmento de bucles de código hasta que se presione CTRL + C ?

Vi en este hilo que el fragmento de código indicado se repite hasta que se presiona la tecla a .

¿Cómo hacer que se repita hasta que se presione CTRL + C ?

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

0

Combinando el hilo indicado con este , he aquí una forma de hacerlo

 // add the event listener to catch the pressing of CTRL+C document.body.addEventListener("keydown",function(e){ e = e || window.event; var key = e.which || e.keyCode; // keyCode detection var ctrl = e?.ctrlKey || (key === 17); // ctrl detection // if CTRL+C is pressed, stop the loop if ( key == 67 && ctrl ) { window.clearInterval(interval); console.log("Ctrl + C was pressed on the browser page (while this one was active)."); console.log("Loop ends!"); } },false); // define the time interval that elapses between the end and the beginning of the loops var x_milliseconds = 1000; // milliseconds // run a function containing the loop commands, every x_milliseconds var interval = setInterval(function() { console.log("The code is looping!"); }, x_milliseconds);

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!