Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
jQuery: How does one bind a field to respond to non-keyboard changes before the field is deselected?

I have a jQuery app with an input text field that has events bound to it such that if the user changes the field then other related fields get updated accordingly. My goal is to make the other fields responsive to every character change. I initially bound the keyup event to the field which works pretty well on a desktop browser:

  1. If a user pastes to the field via typing Ctrl+V, the other fields are immediately updated via the keyboard events.
  2. If the user types into the fields, the other correlated fields are immediately updated with each keystroke.

This seemed perfect.

I noticed, however, when testing on a mobile browser, that if the user presses with their finger in the field and selects paste, the keyup event is not triggered. This isn't surprising since a keyboard isn't being used on the mobile interface. So I additionally bound change to the field. That worked OK, but the user still has to "deselect" the field after pasting for the change event to be triggered. While playing around with things, I noticed that even on the desktop, if the user pastes to the field with the mouse (right click > paste), then no events are triggered until the field is unselected.

Again, my goal is to make the field more responsive than this for these use cases (mouse paste and mobile paste to the field). Is there a keyboardless event I can bind to that will trigger when the user pastes to the field before deselecting the field?

Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The input event is what I want. I find that I can change from binding on keyup change to input and the field is responsive to any change to the field, either via keyboard, changes via the mouse, or touch screen events. Thus:

$("#id_name").on('input', function() {
    // Respond to the change in the field.
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda