2

I have a simple detection if a software keyboard is opened on Android and iOS:

$(document).on({
    focus: function() { keyboardOpened = true; },
    blur: function() { keyboardOpened = false; }
}, 'input'); //catch all focus and blur events fired on any input element

It's used to prevent certain actions while user is writing a message (e.g. ignoring resize events).

It works on all browsers except for Chrome on iOS. I've included Firebug Lite on the site but there is no error, just the events are never fired and the web does not work correctly when opening SW keyboard.

Here is a fiddle: http://jsfiddle.net/WYULR (click the input and see an alert)

Anyone knows about a reason or workaround for this?

Radek Pech
  • 3,032
  • 1
  • 24
  • 29
  • Can anyone at least try the jsfiddle on his iPad/iPhone with Chrome if it works or not? I this there is something wrong with my iPad (actually my boss' iPad) because sometimes when I click the input I get "Share on Facebook" page instead of onfocus :( – Radek Pech Jan 20 '14 at 14:20

1 Answers1

1

I get this too :( My solution is to detect if ipad + chrome using :

var isCriOS = /CriOS/.test(navigator.userAgent);

I tried https://github.com/gabceb/jquery-browser-plugin + webkit type distinguishing code found here How to detect chrome and safari browser (webkit) but I couldn't get that to work.

If ipad+chrome, apply a 'click' event for the field to do the same thing ... this is only good if the only focus you will have is from user taps, as calling .focus() will not trigger it ... but in this case you could just call the function ascribed through click event after the .focus() . This seemed a bit hackish so I decided to test vanilla js .onfocus event and proved that it wasn't firing either.

Community
  • 1
  • 1
J. Barca
  • 538
  • 6
  • 19