我已经定义了在桌面上运行良好的键盘事件,但对于没有获得屏幕键盘事件的触摸设备.如果用户正在输入,我需要捕获.我使用了以下代码段:
I have defined keyboard events which is working good in desktop but for touch devices not getting the onscreen keyboard event. I need to capture if user is typing. I have used the following segment of code :
$('#id').keydown(function(e){
//some code here
});
$('#id').keyup(function(e){
//some code here
})
我希望 keydown 和 keyup 中定义的代码即使对于触摸设备(平板电脑和手机)也能触发.请建议如何捕获屏幕键盘事件并使上述代码运行.
I want the code defined in keydown and keyup to trigger even for touch devices (both tablets and mobiles). Please suggest how to capture the onscreen keyboard event and make the above code to run.
你试过用按键代替按键吗
Have you tried using key press instead of key down
$("#id").keypress(function() {
});
更新:
由于 android 的问题,我现在通常像这样包装我的支票
Due to android problems I now normally wrap my checks like this
if ($.browser.mozilla) {
$("#id").keypress (keyPress);
} else {
$("#id").keydown (keyPress);
}
function keyPress(e){
doSomething;
}
这篇关于如何捕获触摸设备的屏幕键盘“keydown"和“keyup"事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 Angular 2/Typescript 中使用 IScrollUse IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
Anime.js 在 Ionic 3 项目中不起作用anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 项目中不起作用)
Ionic 3 - 使用异步数据更新 ObservableIonic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用异步数据更新 Observable)
Angular 2:在本地 .json 文件中找不到文件Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
在 Ionic 2 中,如何创建使用 Ionic 组件的自定义指In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何创建使用 Ionic 组件的自定义指令?)
将 ViewChild 用于动态元素 - Angular 2 &离子2Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(将 ViewChild 用于动态元素 - Angular 2 amp;离子2)