I'm trying to add an event that triggers when the user hits enter in a text input field, to perform a search.
document.querySelector('input[name="filter-search-tag"]').onkeypress = function(e){
if (!e) e = window.event;
var keyCode = e.keyCode || e.which;
if (keyCode == '13'){
alert('pressed');
}
};
It works perfectly fine on desktop, but on mobile it only works if you hit enter 2 or 3 times. It usually gives 229 as the keycode instead of the proper key. Same thing happens with onkeyup and onkeydown.
Surely there is a way to detect hitting enter on android?