Note that there are some explanatory texts on larger screens.

plurals
  1. PONo keypress events for certain keys in Android browser
    primarykey
    data
    text
    <p>Below code works perfect in Chrome, Firefox, on IPhone, and even in third-party browsers on Android. However, when run within the native browser key events for special characters like Å, Ä, and Ö on my Swedish keyboard are simply not triggered.</p> <p>The example should only allow the user to enter a single character at a time. Works like a charm, unless I in android press keys like Å, Ä or Ö for which I can enter any number of characters.</p> <p>Here's a jsFiddle for any who wish to try it out: <a href="http://jsfiddle.net/x7H6f/">http://jsfiddle.net/x7H6f/</a>. If u don't have special keys like my Swedish ones printed on your keyboard, characters like é (hold E) should do the "trick".</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;Key Event test&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="text" id="a" name="test" /&gt; &lt;script&gt; document.getElementById("a").onkeypress = function(e) { e = e || window.event; var k = e.keyCode || e.which; this.value = String.fromCharCode(k); return false; } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And no, keydown and keyup don't work either. Did I miss something, or is this a bug? It's horribly annoying when developing Swedish Apps in PhoneGap!</p> <p>Thanks!</p> <hr> <p><strong>EDIT:</strong> As Manor says in his answer, the <code>input</code> event can be used. Here's a fiddle which demonstrates the differences between the <code>keypress</code>, <code>input</code>, and <code>change</code> events: <a href="http://jsfiddle.net/Qxd76/">http://jsfiddle.net/Qxd76/</a> (use <a href="http://jsfiddle.net/Qxd76/show">http://jsfiddle.net/Qxd76/show</a> to view the result on a smartphone).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload