backSpace 不触发 android mobile 中的 keyup 事件 [英] backSpace not firing the keyup event in android mobile
问题描述
这是第一次,我正在处理 mobile Apps
.keyUp
事件不会触发如果我按下 backspace
按钮.
This is the first time,I am working on mobile Apps
.keyUp
event not firing If I press backspace
button.
我做了一个 jsFiddle 以供参考.
I made a jsFiddle for reference.
最初用户输入 23
,然后用户使用退格按钮删除 3
.同时输入 23
事件触发但删除时间事件未触发.
Initially user entered 23
and then user deleted 3
using backspace button.While entering 23
event firing but while delete time event not firing.
我使用的是设备:motorola motog,安卓版本:4.4.2
.
我该如何解决这个问题,谁能帮我提供示例代码.
How can I fix this,can anyone help me with an example code.
推荐答案
问题是自 Android 4.4 以来 Chrome 停止为退格键"触发按键事件.在许多基于 webview 的应用程序中,这在捕捉所需事件方面存在问题.通过使用 input
事件,只要用户键入内容、粘贴内容或点击键盘上的.com"按钮等,就会触发该事件,从而减轻了一些压力.
The problem is somewhere Chrome stopped firing keypress events for "backspace" since Android 4.4. This has been problematic in many webview based apps to catch required events. There is a small relief from this by using the input
event that fires whenever user types something, pastes something, or taps on ".com" button in the keyboard, etc.
如果您只想捕获对输入的更改,最好依赖 input
事件.如果您想阻止默认操作,则它没有用.
It is best to rely on input
event if you are looking only to capture changes to the input. It is not useful if you want to do preventing default actions.
对于您的情况,我认为它应该适合.但请注意,Android 4 之前版本支持此事件.
For your case, I think it should fit. But beware, of the support for this event for earlier than Android 4 version.
更新小提琴 - http://jsfiddle.net/aravindbaskaran/33Snz/24/
这篇关于backSpace 不触发 android mobile 中的 keyup 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!