Question

So, I have a keyup event for whenever you type into a form, and it works perfectly for every key, except d. If I press any key, that key gets detected, but the first d would not get detected. For instance, if I type d, the d will not get detected, but if I type dd, the second d will get detected.

Simple demo:

$(".navbar-form").on("keyup", function (data) {

  var text = $('.form-control')[0].value;
  $.ajax({
    url: '/users/search',
    type: 'GET',
    data: {text: text},
    success: function(responseData) {
      //do what you plan to do with data
    }
  });
})
Was it helpful?

Solution

You either:

a. Have a bad keyboard,

b. Have some external code from some library or somewhere else in your page or application that is catching a d keypress and preventing the event from bubbling.

So,

  1. It certainly has nothing to do with the code you posted (see zerkms' comment), and

  2. If you want it resolved, you will either have to post more code, or start debugging the code we cannot see. Do a process of elemination. Delete everything else in your page. Does it still not work? Play around. You won't get any more insight here with what you have posted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top