哪里" showkeyboard"从事件来吗? [英] Where is the "showkeyboard" event coming from?

查看:108
本文介绍了哪里" showkeyboard"从事件来吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PhoneGap的,我需要赶上键盘显示事件上的Andr​​oid手机。

I am using PhoneGap and I need to catch a "keyboard is showing" event on android phones.

我发现某些线程说,用showkeyboard事件。 (这一次例如:<一href=\"http://stackoverflow.com/questions/11686368/show-hide-keyboard-is-not-working-propery-in-android-phonegap\">Show隐藏键盘不工作在Android中的PhoneGap 属性格式)

I've found some threads saying to use the "showkeyboard" event. (This one for example : Show hide keyboard is not working propery in android phonegap)

我的提问:这是与PhoneGap的可用的机器人的事件?这是一个简单的PhoneGap的事件?这是一个浏览器的事件?这是一个经典的JavaScript事件?

My question : Is this an android event usable with phonegap? Is this a simple phonegap event? Is this a browser event? Is this a classical javascript event?

我没有找到该事件的任何文档,我需要它,因为它也对方向改变射击...

I don't find any doc on this event, and I need it because it's also firing on orientation change...

编辑:我发现这一点,说从android的,但无证的:的https:/ /issues.apache.org/jira/browse/CB-6154

I've found this, saying it's from android but undocumented : https://issues.apache.org/jira/browse/CB-6154

推荐答案

这些事件是由的Andr​​oid ,但未记录即可。我遇到了一些麻烦与此,所以我不建议使用它们。

These events are from Android but are not documented. 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';
};

和我做的'hidekeyboard事件同样的事情。希望这会有所帮助。

And I've done the same thing with the 'hidekeyboard' event. Hope this will help.

还有一个问题(yirk之间!):键盘可能会略微型动物。如果小键盘的变化:hidekeyboard'事件被触发....

There's another problem (yirk!): keyboards may be slightly differents. If the keyboard changes for a smaller: the 'hidekeyboard' event is fired....

这篇关于哪里&QUOT; showkeyboard&QUOT;从事件来吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆