I think this will work for your needs -
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady () {
document.addEventListener('hidekeyboard', onKeyboardHide, false);
document.addEventListener('showkeyboard', onKeyboardShow, false);
}
function onKeyboardHide() {
console.log('onKeyboardHide');
}
function onKeyboardShow() {
console.log('onKeyboardShow');
}
// edit
Since you cannot hook into those events you need a plugin. This one here will do the trick.
To install the plugin perform cordova plugin add com.ionic.keyboard
// This event fires when the keyboard will be shown
window.addEventListener('native.keyboardshow', keyboardShowHandler);
function keyboardShowHandler(e){
console.log('Keyboard height is: ' + e.keyboardHeight);
}
// This event fires when the keyboard will hide
window.addEventListener('native.keyboardhide', keyboardHideHandler);
function keyboardHideHandler(e){
console.log('Goodnight, sweet prince');
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…