I have this simple code that just clicks a button when ever a user clicks the enter button.
It works perfectly on desktop and IOS devices but doesn't on android devices. What do I need to add to make it work on Android devices as well
// clicks search button on enter
useEffect(() => {
document
.getElementById("navBarSearchForm")
.addEventListener("keydown", function (event) {
if (event.code === "Enter" || event.code === "NumpadEnter") {
event.preventDefault();
document.getElementById("searchbutton").click();
}
});
}, []);