newprogrammer
newprogrammer

Reputation: 1

js onkeyup does not work on mobile devices

function SpaceFunction() {
  var x = document.getElementById("removespace");
  x.value = x.value.replace(/ /g, "");
}

and :

function Count() {  
    var i = document.getElementById("mylabel").value.length;  
    document.getElementById("display").innerHTML = 150 - i; 
}

why does not work on mobile devices? and What should I do?

Upvotes: 0

Views: 389

Answers (1)

Tom
Tom

Reputation: 159

Some mobile and virtual keyboards do not fire keypress events and use the compositionupdate event. I had this problem before and just had to add a listener for both keyup and compositonupdate

Upvotes: 1

Related Questions