Adobe PhoneGap构建中的iOS键盘事件



Adobe PhoneGap构建中是否存在键盘事件?或将使它们暴露的插件。具体来说,我想将回调附加到显示和隐藏的键盘上。

我目前在输入上使用焦点和模糊事件,但我宁愿听键盘本身。

有一个插件可以帮助您解决此问题:https://github.com/mhweiner/cordovaioskeyoskeyboardplugin

基本上可以让您做这样的事情:

// See if keyboard is open or not
var is_open = Keyboard.isOpen();
// Get height of open keyboard (including inputAccessoryView toolbar)
var height = Keyboard.getHeight();
// The following jQuery events are available:
// keyboardWillShow, keyboardDidShow, keyboardWillHide, keyboardDidHide
// Set callback
$('body').on('keyboardWillShow', myCallback);
// Remove callback
$('body').off('keyboardWillShow');

可以在readme文件中找到git repo。

我已经使用了普通柯达(Cordova)上的离子键盘,但在这里也可用于phonegap构建,它像android上的魅力一样起作用,但它是乘坐的型号,并且在Android和iOS上都可以使用,以及一些额外功能以及一些额外功能的功能iOS,但您想要的功能是多平台:在您的config.xml上添加此之后:

<gap:plugin name="com.ionic-for-phonegap.keyboard" version="0.0.1" />

然后在设备准备就绪上使用此信息:

//add event listeners
window.addEventListener('native.showkeyboard', keyboardShowFunction);
window.addEventListener('native.hidekeyboard', keyboardHideFunction);
//the handlers
//here if you want keyboard height use e.keyboardHeight in keyboardShowFunction to get it
function keyboardShowFunction(e){
    alert('Keyboard is on');
}
function keyboardHideFunction(e){
    alert('key board is off');
}

GitHub上描述的更多功能

最新更新