我们正在使用IBM Worklight 6.1开发混合移动应用程序。
对于iOS,如何处理"搜索"显示软键盘上的按钮事件?
答案 0 :(得分:0)
"处理"有点模糊......你想要完成什么? 如果为特定需要调用正确的键盘,则不需要检测任何按钮。
仅当input
标记位于form
元素内时,才会显示iOS键盘中的搜索按钮。
例如:
// This will display a return button.
<input id="textField" type="text"/>
// This will display a search button.
<form>
<input id="searchField" type="search"/>
</form>
在JavaScript中,您可以使用jQuery keypress
事件在点按搜索按钮后触发操作。例如:
$("#searchField").keypress(function() {
alert("Handler for .keypress() called.");
});
你也可以&#34;检测&#34; &#34;类型&#34;键盘的情况,在&#34;搜索&#34;的情况下,如下所示(但这有点明显......):
if ($("#searchField").attr("type") == "search") {
alert("This search field is of type 'search'.");
}
否则,您将需要实现本机代码(意味着Cordova plug-in)来检测当前显示的键盘的类型并执行操作等...