jQuery在chrome和IE上获取keypress事件

mr_*_*app 1 javascript firefox jquery google-chrome keypress

我有一个问题,在chrome和IE上获取事件"keypress".在Firefox上它运作良好.

function bind_input_keypress ($this) {  
    $($this).bind('input', function() {
        $($this).css('width',$($this).val().length*5.5+20);
    })
    $($this).bind('keypress',function(e) {
        /*  delete last extra... */
        if( e.keyCode == '8' && $($this).val()=='' ) { $('#extras b').remove(); }

        /* arrow up */
        if( e.keyCode == '38' ) {
            console.log('38 pressed');
        }
        /* arrow down */

        if( e.keyCode == '40' ) {
            console.log('40 pressed');
            ad_curr     = $('.ad_selectbox .autocomplete ul li.active');

        }
    });
}
$('input').focus(function(){
    bind_input_keypress($(this));
})
Run Code Online (Sandbox Code Playgroud)

为什么这不适用于chrome和IE?

你也可以在jsfiddle上查一下 http://jsfiddle.net/a5M6S/2/

ama*_*ma2 5

我认为,问题是,keypress在Chrome事件不会解雇箭头键,而不是 keydownkeyup被解雇.我相信它对IE来说是一样的.