jQuery keyboard events

后端 未结 4 812
萌比男神i
萌比男神i 2020-11-29 13:31

Using jQuery, I would like to capture a keyboard event that is:

  • before the user lifts their finger from the key
  • after the characters
4条回答
  •  情歌与酒
    2020-11-29 14:05

    You can use setTimeout:

    $('input').keypress(function() {
        var that = this;
        setTimeout(function() {
            // read that.value
        }, 0);
    });
    

    Live demo: http://jsfiddle.net/HpXuU/8/

提交回复
热议问题