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

257
Views
lodash debounce ignorar tecla de espacio

hola, estoy trabajando con lodash... todo funciona muy bien... pero tengo un problema, quiero que debouce no funcione cuando se presiona la tecla enter... y esta es mi tecla lodash...

 search_products:_.debounce(function(event) { // my code here // how can i let debounce work with all keys but not with enter key },5),

quiero que el retraso de 5 ml no funcione con enter también si hay algún otro método como debouce o cualquier otra biblioteca ¿alguien puede ayudarme aquí es posible gracias

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

0

Puede extraer la función rebotada y solo llamarla cuando se presiona algo que no sea la tecla Intro.

 { search_products: function (event) { if (event.code !== 'Enter') { debounced(event); } } } const debounced = _.debounce(function(event) { // ... }, 5);
about 4 years ago · Juan Pablo Isaza Report

0

Puede usar el método flush() incluido con lodash debounce

flush invocará inmediatamente todas las invocaciones de funciones retrasadas.

Escriba a continuación y habrá un retraso de 1 segundo, pero presione enter y registrará el resultado de inmediato.

 const debounced = _.debounce(value => { console.log(value); }, 1000); const handler = event => { if (event.key === 'Enter') return debounced.flush(); debounced(event.target.value); } document.querySelector('input').addEventListener('keyup', handler);
 <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <input type="text" placeholder="type something">

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!