[英]Where is the “showkeyboard” event coming from?
I am using PhoneGap and I need to catch a "keyboard is showing" event on android phones. 我正在使用PhoneGap,我需要在Android手机上捕获“键盘正在显示”事件。
I've found some threads saying to use the "showkeyboard" event. 我发现一些线程说要使用“ showkeyboard”事件。 (This one for example : Show hide keyboard is not working propery in android phonegap )
(例如: 显示隐藏键盘在android phonegap中无法正常工作 )
My question : Is this an android event usable with phonegap? 我的问题 :这是可与phonegap一起使用的android事件吗? Is this a simple phonegap event?
这是一个简单的phonegap事件吗? Is this a browser event?
这是浏览器事件吗? Is this a classical javascript event?
这是经典的javascript事件吗?
I don't find any doc on this event, and I need it because it's also firing on orientation change... 我没有找到有关此事件的任何文档,我需要它,因为它还会触发方向更改...
EDIT: I've found this, saying it's from android but undocumented : https://issues.apache.org/jira/browse/CB-6154 编辑:我发现了这个,说这是从android上来的,但未记录在案: https : //issues.apache.org/jira/browse/CB-6154
These events are from Android but are not documented . 这些事件来自Android , 但未记录 。 I've encountered some trouble with this so I recommend not using them.
我遇到了一些麻烦,所以我建议不要使用它们。
For information, in order to make my function work, I've done something like this (this is just the general idea): 为了提供信息,为了使我的功能正常工作,我已经做了类似的事情(这只是一般性的想法):
this._keyboardTimer;
document.addEventListener('showkeyboard', function (e) {
clearTimeout(this._keyboardTimer); // keep only the last event
this._keyboardTimer = setTimeout(function(oldOrientation){
if (oldOrientation != getOrientation()) {
/* this is an orientation event */
} else {
/* keyboard is really opening */
}
}.bind(this, getOrientation()), 200);
}.bind(this), false);
function getOrientation() {
return ( (window.orientation == 90) || (window.orientation == -90) )
? 'landscape'
: 'portrait';
};
And I've done the same thing with the 'hidekeyboard' event. 我在'hidekeyboard'事件中也做了同样的事情。 Hope this will help.
希望这会有所帮助。
[EDIT] There's another problem (yirk!): keyboards may be slightly differents. [编辑]还有另一个问题(奇怪!):键盘可能略有不同。 If the keyboard changes for a smaller: the 'hidekeyboard' event is fired....
如果键盘更改为较小的键盘:则触发“ hidekeyboard”事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.