Detecting hidden keyboard button on Ipad Iphone in Javascript

I am trying to intercept " Hide keyboard " for Ipad in Javascript. I've searched everywhere but couldn't find the correct code for this. I pressed any keys and I get a keycode map (for characters, but also for enter, space and delete ..).

This is an example of what I want to accomplish

$( "#mydiv" ).on( "keydown", function( event ) {
   if (event.which == xx){
      //do something
    }
}

      

where xx is my code on the "Hide Keyboard" button. When the button is clicked, no method is called to the delegate, not the KeyCode.

I took a look at detecting iPad key to hide iPad , but I am getting a solution on a different level (with Xcode), but I need a solution with Javascript.

Hope someone can help.

enter image description here

+3


source to share


1 answer


I found a desktop for iPad IOS7. I will be testing on IOS8 to make sure it works. So basically I create a listener on every FOCUSOUT event (for all my texts) and I call my function.

It fires when you open the keyboard and close the "keyboard". It doesn't fire when you select another textbox or button because it targets zero. If used in conjunction with keydown, you can store multiple values ​​and only call the submit function when you release the keyboard. It works for my specific project.



 document.addEventListener('focusout', function(e) {
        if (e.relatedTarget == null){
            alert("close keyboard without click on something else");
            callYourFunction();
           }
    });

      

ps I'm new to SO so don't know if I can answer myself, or if I need to modify my question or make a comment.

+3


source







All Articles