Jquery unbind('keydown') not working properly

Jquery unbind('keydown') not working properly

Good morning

I have a slight problem in FF3.5 that unbind('keydown'); is not working properly..

$("#q").unbind('keydown');
$("#q").keydown(function(e){
    var code = (e.keyCode ? e.keyCode : e.which);
    if(code==40 || code==38) {
    var totalResults=$("#quick-search-results li");
    var selectedResults=$("#quick-search-results li.qs-selected");
        if(code==40) {

            var nodeIndex=($("#quick-search-results li.qs-selected").length<=0) ? 0 : $("#quick-search-results").index('li.qs-selected');
           
         
            alert(nodeIndex);
           
         }
    }
}); // end keydown

The above code alerts once on first keydown (with the down arrow key [code==40]), twice on the second, three times on the third and so on.. it worked fine in FF3 but a recent upgrade to FF3.5 seems to have broken the functionality..

Has anyone else had this problem ?

Thanks in advance.

Alex