Learning by sharing

安卓上的 onkeydown 事件监听

有些安卓手机 web 上面无法通过 onkeydown 监听 textarea/input 元素的 backspace 删除事件,其他事件可以响应。
解决办法是监听 oninput 事件来实现:
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.
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.