Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

264
Vistas
lodash debounce ignore space key

hi im working with lodash .. everything working so good .. but i have problem thats i want debouce not working when enter key is pressed .. and this is my lodash key ..

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

i want the delay 5ml not working with enter also if there is any ather method like debouce or any anther library can anyone help me here is that possable thanks

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can extract the debounced function and only call it when something other than the enter key is pressed.

{
  search_products: function (event) {
    if (event.code !== 'Enter') {
      debounced(event);
    }
  }
}

const debounced = _.debounce(function(event) {
  // ...
}, 5);
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use the flush() method included with lodash debounce

flush will immediately invoke all delayed function invocations.

Type below and there will be a 1 second delay, but hit enter and it will log the result immediately.

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda