Does javascript read keystrokes on a tablet?

I have this interesting problem - I would like to read keystrokes using javascript, but not direct them to the text box.

It's just on computers, and I have this job (as long as the window has focus, javascript can detect keystrokes). However, on tablets running Android and iOS, the operating system ignores keystrokes. The javascript code only gets the keystroke data if I focus on the text field.

Is there any way around this? I would like to read keystrokes on tablets without having to focus in the text box.

+8
javascript mobile tablet keypress
source share
3 answers

Try something like this:

$('input,textarea').live("keypress", function (e) { //do any action here }); 
+1
source share

From what I saw with the iPad for more than 2 years, and writing my own network games, I came to the conclusion that the iPad only activates its keyboard when the form input field is concentrated . This means that the web page user cannot enter keyboard input if the input field of the form has not been focused.

This means that you are requesting physical impossibility on these devices.

+1
source share

Instead of a key event, you can simply use input. Worked for me.

  var userList = new List("MyListList", options); $(".main-search").on("input", function () { userList.search($(".main-search").val()); }); 
0
source share

All Articles