OnKeyPress, onKeyDown, onKeyUp events not fired in Firefox/Chrome under Android when typing letters

android, firefox, google-chrome, javascript

Solution

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

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

OR

<input type="text" onkeydown="return myFun();">

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

Problem

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 letters, but when typing "%" sign or pressing the space bar for example, it does. In the Android "preinstalled" browser everything woks fine. Another very rare thing, the behaviour is different if my cursor is not the last character... If my cursor is in the middle of the text, under Firefox all events are fired for any key. In Chrome event onkeyup and onkeydown are fired twice for one key pressed, but onkeypress is not fired. I tested it on different devices, with similar issues. I could not find any similar issue reported on Internet. Did someone already face this problem before? How did you fix it? Sites like Amazon.com work fine for autocomplete, so there must be a workaround... Please note the issue disapeared in recent versions of Firefox and Chrome Many thanks in advance for your help. ``` <!DOCTYPE html> <html> <head> </head> <body> <h1>onKeyXxx event test</h1> <input type="text" onkeydown="alert('DOWN');" onkeypress="alert('Press');" onkeyup="alert('UP');"> <hr/> </body> </html> ```

Original source

Related problems