+ 9
Why does android keyboard always return 229?
document.getElementById("id").addEventListener("keydown", function(e){ alert(e.which); }); Why does it always return 229?
6 Respuestas
+ 5
Lots of people were confused about this.
It always returns 229 because it is a W3C standard to return 229 when an "Input Method Editor" is processing and the event is keydown. It appeared in a 2010 W3C spec linked below.
You may want to listen to keypress instead of keydown.
You can read more by seeing:
- https://lists.w3.org/Archives/Public/www-dom/2010JulSep/att-0182/keyCode-spec.html "How to calculate keyCode for keydown and keyup events"
- https://codepen.io/ashconnolly/pen/WyWgPG "android keycode detection - 229 issue fix"
- https://social.msdn.microsoft.com/Forums/en-US/d9ac5d52-55f5-4e8f-b074-22323834a09c/keydown-event-always-returns-keycode-229?forum=vssmartdevicesvbcs "KeyDown event always returns KeyCode 229"
- https://github.com/nosir/cleave.js/issues/147 "onKeyDown code not working on android mobile browsers"
+ 1
Go to stackoverflow hopely you will find your answer
0
html
0
Shree.
0
html
0
var editor=document.getElementById('in')
editor.addEventListener('keyup', function(event){
var editorText=event.target.innerText
var ediorLastAlpha=editorText[editorText.length-1]
var splited=ediorLastAlpha.trim()
if(splited.length==0){
alert('give some space huh')
}
}
)