[英]In my Cordova project, I want to trigger a function(search functionality) on iOS keyboard 'done' button click
Is there anyway to solve this problem from native code. 无论如何,从本机代码解决此问题。
Please ignore below two solutions:- 请忽略以下两种解决方案: -
As far as I analyzed, the good approach is to use Cordova keyboard plugin and listen for 'keyboardDidHide' event which will be fired on press of "Done" key. 据我分析,好的方法是使用Cordova键盘插件并收听'keyboardDidHide'事件,该事件将在按下“完成”键时触发。 But ensure to deregister this event once you are done with the desired operations on click of "Done" key.
但是,一旦完成了单击“完成”键所需的操作,请确保取消注册此事件。
Sample code snippet as follows: 示例代码段如下:
window.addEventListener('keyboardDidHide', function () {
// logic which needs to be executed on click of "Done" key
// Deregiter 'keyboardDidHide' event
});
More info on Cordova Keyboard Plugin is available on official github page . 有关Cordova Keyboard Plugin的更多信息,请访问官方github页面 。
$(document).keydown(function(e) {
switch(e.which) {
case 13: // enter button
break;
default: return; // exit this handler for other keys
}
e.preventDefault(); // prevent the default action (scroll / move caret)
});
You can check all the char code for keys here : http://www.cambiaresearch.com/articles/15/javascript-key-codes 您可以在此处查看密钥的所有字符代码: http : //www.cambiaresearch.com/articles/15/javascript-key-codes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.