Search code examples
jquerykeypressjquery-selectbox

Jquery keypress not firing while selectbox is open in IE


I'm trying to get selectbox to behave like a normal html selectbox. What I want is when you press a key it will jump down to the next option that starts with that letter, however, in IE while the select box is open, im unable to detect the keypress:

$(document).ready(function(){

    $('select').selectbox();
    $(document).keypress(function(){
          alert('working'); 
    });
});

http://jsfiddle.net/fvFp7/3

The jfiddle works in chrome and firefox but not IE9.

I've had similar problems using keydown. Delegate may be a solution but I'm not sure how it works.

Is there a way to detect a keypress in IE while the dropdown is open?


Solution

  • Yes, keyup works.

    $(document).keyup(function(){
          alert('working'); 
    });
    

    updated jsFiddle

    As a side note, keyup is generally the best way to register keypress events, unless you are specifically looking for multiple-key combinations.