Ionic Keyboard show event fired multiple times


#1

I am using this sample code:
window.addEventListener(‘native.keyboardshow’, keyboardShowHandler);

    function keyboardShowHandler(e){
        console.log('Keyboard height is: ' + e.keyboardHeight);
    }

And when the screen rotates the event is fired more then once, up to three times, each time keyboardHeight has a different value. Is that normal?


#2

Yup, should be normal. We’re looking at what the view’s size is and just making sure we know what the size of keyboard will be.

https://github.com/driftyco/ionic/blob/master/js/utils/keyboard.js


#3

I have to admit that I did not understand the purpose behind this… But, is there a way to subscribe only for the “last” event?


#4

Hmm, actually there shouldn’t be more that one event firing for each input focus. Can put a codepen together of what you have?


#5

You are right about the focus - it is triggered only once.
What I meant is that once your keyboard is on the screen and you rotate the screen, then the event is fired more then once.

The idea is that I am doing something based on the keyboard height, thus I am doing the same thing for up to three times for different keyboard heights, I would, of course, like to do that only once, for the “last” value that is fired.


#6

Hmm, doesn’t seem to be doing that for me. I get one event when I rotate and there’s focus on an input. Are you on android or ios?


#7

Same issue for me: after rotating the device and focusing an input it triggers the show/hide/show/show events.

Using Nexus 5 Android 5.1.1