jQuery: textbox keyup firing twice

前端 未结 8 1861
南笙
南笙 2021-01-11 16:09

I\'m having a textbox and assigned the following function (it\'s the only function assigned):

txt.bind(\"keyup\",function(event){
    if(event.keyCode==13)
          


        
8条回答
  •  一整个雨季
    2021-01-11 16:43

    I'm embarrassed to even mention this, but I was typing a capital letter into my textbox and so the release of my shift key was causing the supposed "second firing" of the keyup event. Turns out it wasn't a second firing at all, but it just fooled me into thinking it was for while. At first I thought the unbind trick mentioned above simply wasn't working for me, but it was. I hope this helps others like me that might have done the same thing. Now I simply make sure I always check that its not just the shift key being released in the handling of my event and all is well again.

提交回复
热议问题