Ionic Keyboard show event fired multiple times

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?

1 Like

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

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?

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

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.

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?

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