Ionic.keyboard.isOpen?


#1

I have an $ionicPopup.alert, but I don’t want it to pop up when the keyboard is open. I thought I could simply test ionic.keyboard.isOpen but it doesn’t seems to work. I can create my own flag like this and it works fine:

var keyboardIsOpen = false;
window.addEventListener('native.keyboardshow', function keyboardShowHandler(e) {keyboardIsOpen = true;});
window.addEventListener('native.keyboardhide', function keyboardShowHandler(e) {keyboardIsOpen = false;});
setInterval(function(){
    if (!keyboardIsOpen) {        // why not ionic.keyboard.isOpen ?
        $ionicPopup.alert({title:'Alert',template:'Doh!'});
    }
}, 5000);

Is there a better way to do this?

(I do have the Ionic keyboard plugin loaded obviously, since the event listeners are picking up native.keyboardshow/hide.)


#2

Hmm, can you throw this into a codepen? I can check this out in the morning.


#3

codepen won’t show the popup keyboard, right? Really need to try this on an emulator I think.


#4

Yes, the codepen wouldn’t show a keyboard, but I can take the codepen and throw it into a project for testing :smile:


#5

Okay, please try this codepen: http://codepen.io/elainerhodes/pen/uhGFB