Skip to content Skip to sidebar Skip to footer

Onkeypress, Onkeydown, Onkeyup Events Not Fired In Firefox/chrome Under Android When Typing Letters

I have an issue with Firefox/Chrome under Android. When I type text into an input box (see code below), the onkeypress, onkeyup, and onkeydown events are not fired when typing lett

Solution 1:

The setInterval did the trick.

Not sure yet how I will implement it inside Script.aculo.us (the library I use for autoselect drop down) but I will find a way.

Here is an example of the solution implementing setTimer :)

<!DOCTYPE html><html><head><script>
typedText="";
functioncheckTextChange(){
    if (document.getElementById("test").value != typedText){
        typedText=document.getElementById("test").value;
        document.getElementById("output").innerHTML=typedText;
        returntrue;
    } else {
        returnfalse;
    }
}
if (navigator.appVersion.indexOf("Android")>-1 && (navigator.appVersion.indexOf("Safari")==-1 || navigator.appVersion.indexOf("Chrome")>-1)){
    alert("Using work around");
    var myVar = setInterval(function(){checkTextChange();},200);
}
 </script></head><body ><h1>onKeyXxx event test</h1><form><inputtype="text"name="test"id="test"onkeydown="checkTextChange();"onkeypress="checkTextChange();"onkeyup="checkTextChange();"></form><divid="output"></div><hr></body></html>

Solution 2:

You Can not Give alert Directly Follow any of the way from following

<inputtype="text" onkeydown="JavaScript:return alert('DOWN');">

OR

<inputtype="text" onkeydown="return myFun();">

Where you can define your function between and tag anywhere in document.

Post a Comment for "Onkeypress, Onkeydown, Onkeyup Events Not Fired In Firefox/chrome Under Android When Typing Letters"