Find Android device keyboard height in Ionic - Cordova

window.addEventListener can be used to identify the native keyboard height. This addEventListener function attaches the native.keyboardshow event listener where the callback function triggered when native keyboard gets enabled.

Syntax:

window.addEventListener('native.keyboardshow', callBackFunction);
function callBackFunction(e) {
    // code to find keyboard height.
}

Example Code:

var myApp = angular.module("myApp", []);
myApp.controller('myController', function($window) {
    window.addEventListener('native.keyboardshow', keyboardShowHandler);
        function keyboardShowHandler(e) { // fired when keyboard enabled
            var keyboardHeight = e.keyboardHeight;
            alert(keyboardHeight);
        }
    }
});

Sample Output Screen:

samp.PNG

 

Category: