科尔多瓦3.4 - 检测键盘事件科尔、键盘、多瓦、事件

由网友(5个半柠檬c)分享简介:我想检测这两个事件:showkeyboard和hidekeyboard上运行感谢科尔多瓦3.4.0和jQuery移动1.4.2我的申请。在配置文件中,全屏attribut设置为true(我需要它)。I'm trying to detect those two events : showkeyboard and hid...

我想检测这两个事件:showkeyboard和hidekeyboard上运行感谢科尔多瓦3.4.0和jQuery移动1.4.2我的申请。在配置文件中,全屏attribut设置为true(我需要它)。

I'm trying to detect those two events : showkeyboard and hidekeyboard on my application running thanks to Cordova 3.4.0 and JQuery Mobile 1.4.2. In the configuration file, fullscreen attribut is set to true (I need it).

事实上,在LogCat中,我无法读取(AP prently这是由于全屏模式):

The fact is, in LogCat, I can't read (apprently it's due to the fullscreen mode) :

SoftKeyboardDetect:忽略此事件

SoftKeyboardDetect : Ignore this event

有没有什么解决方案来检测这个两个事件?我用我的输入字段检测模糊和焦点事件尝试的另一种方式。它的工作原理,但是当键盘被关闭感谢后退按钮,这些事件都不会被调用。

Is there any solution to detect this two events ? I tried an alternative way by detecting blur and focus events on my input field. It works, but when the keyboard is closed thanks to the back button, those events are not called.

所以,我试图检测后退按钮事件,但它不工作(http://simonmacdonald.blogspot.fr/2011/05/overriding-back-button-in-phonegap.html).

So, I tried to detect the backbutton event but it doesn't work (http://simonmacdonald.blogspot.fr/2011/05/overriding-back-button-in-phonegap.html).

感谢您的建议对您有所帮助。

Thanks in advice for you help.

推荐答案

我觉得这会为您的需求 -

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');
}

//修改

由于无法挂接到这些事件,你需要一个插件。 这个人在这里会做的伎俩。

Since you cannot hook into those events you need a plugin. This one here will do the trick.

要安装该插件执行科尔多瓦插件添加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');
}
阅读全文

相关推荐

最新文章