Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is anybody else having problems with the keyup event in iOS 9 not firing?

Just a simple test bed replicates the issue for me.

<input id="txtInput" />

Vanilla JS:

document.getElementById('txtInput').onkeyup = function () {
    console.log('keyup triggered');
}

jQuery:

$('#txtInput').on('keyup', function () {
    console.log('keyup triggered');
});

Neither fire...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
706 views
Welcome To Ask or Share your Answers For Others

1 Answer

I suggest using the keypress event on browsers with touch screens. I know that you can't really detect touch screen screens, though, so it leaves you with a few options that your situation will likely dictate.

  1. Attach both events keyup and keypress. This would likely be dependent on how much processing is going on and if you are getting double-fires in some browsers.
  2. Attempt to determine whether the browser is a touch screen (like using Modernizr), and then attach a fallback handler like change.

Either way, you end up with two event listeners.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...