Why does JQuery keydown work for window but not textbox?

Posted by Edward Tanguay on Stack Overflow See other posts from Stack Overflow or by Edward Tanguay
Published on 2008-10-09T13:24:15Z Indexed on 2010/03/27 1:13 UTC
Read the original article Hit count: 385

Filed under:

Why does this work:

$(window).keydown(function(event){
    alert(event.keyCode);
});

but not this:

$('#ajaxSearchText').keydown(function(event){
    alert(event.keyCode);
});

I'm testing with Firefox 3. Interestingly, neither of them work in IE7.

© Stack Overflow or respective owner

Related posts about jQuery