+ 9

Why does android keyboard always return 229?

document.getElementById("id").addEventListener("keydown", function(e){ alert(e.which); }); Why does it always return 229?

17th Jul 2019, 8:11 PM
Nerderkips
Nerderkips - avatar
6 Answers
+ 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"
18th Jul 2019, 1:57 AM
Josh Greig
Josh Greig - avatar
+ 1
Go to stackoverflow hopely you will find your answer
19th Jul 2019, 6:48 AM
Hafiz usama
0
html
18th Jul 2019, 11:13 AM
Arjun Yadav
Arjun Yadav - avatar
0
Shree.
18th Jul 2019, 11:14 AM
Arjun Yadav
Arjun Yadav - avatar
0
html
18th Jul 2019, 2:30 PM
Rahul minj
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') } } )
30th Apr 2021, 9:45 AM
anand Pandit
anand Pandit - avatar