javascript 如何使用javascript检测android设备中的键盘关闭事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11061011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 11:58:21  来源:igfitidea点击:

How to detect keyboard close event in android device with javascript

javascriptandroidcordovakeyboard-events

提问by JDev

I'm developing android application with phonegap. Currently I'm facing one problem with inputboxproblem with specific HTC Android device and I have a solution for that. But I need to know when keyboard close event occurred.

我正在使用phonegap开发 android 应用程序。目前inputbox,我遇到了一个与特定 HTC Android 设备有关的问题,我有一个解决方案。但我需要知道键盘关闭事件何时发生

so my question is how to detect keyboard close event with phonegapor any plugins available to detect keyboard event for android device.?

所以我的问题是如何使用 phonegap或任何可用于检测 android 设备键盘事件的插件来检测键盘关闭事件。?

Please help. Thanks in advance.

请帮忙。提前致谢。

采纳答案by Pedantic

I don't use Phonegap, but I did some rudimentary Google searches like 'phonegap android hide keyboard event' and came across these two relevant posts from a few months ago.

我不使用 Phonegap,但我做了一些基本的谷歌搜索,比如“phonegap android 隐藏键盘事件”,并在几个月前发现了这两个相关的帖子。

First one is right here on SO: Android SoftKeyboardDetect: Ignore this event what does it mean?. It looks like if you drop down to "native" Java(...) Android tries to make this available.

第一个就在这里: Android SoftKeyboardDetect:忽略此事件是什么意思?. 看起来,如果您下拉到“本机”Java(...),Android 会尝试使其可用。

This other one, Re: [PhoneGap] Re: SoftKeyboardDetect(328): Ignoreon a phonegap-oriented website seems to suggest that the phonegap implementation or the SoftKeyboardDetect code is to blame.

另一个,回复:[PhoneGap] 回复:SoftKeyboardDetect(328):在面向 phonegap 的网站上忽略似乎表明应该归咎于 phonegap 实现或 SoftKeyboardDetect 代码。

I have Android code written in Java where it works just fine.

我有用 Java 编写的 Android 代码,它运行良好。

回答by ikeygeek

I have faced similar problem for iPhone app development with phonegap. I have fixed the problem with the following way.

我在使用 phonegap 开发 iPhone 应用程序时遇到了类似的问题。我已经通过以下方式解决了这个问题。

$("input[type=text], textarea").
bind("blur", function(e) {
 window.scrollTo(0.0);
 loaded();
});

You can detect the close event with 'blur' action.

您可以使用“模糊”操作检测关闭事件。

回答by agarcia

I use :

我用 :

 inputElement.bind("closeKeyboard", function() {
             //do something
 });