I'd like to have the search field on my website automatically gain focus when the user loads the page, but i don't like how that pops up the keyboard for users on smartphones/tablets. Is there any javascript property I can use to detect whether or not the user has physical keyboard connected?
In plain JavaScript, you can use the EventTarget. addEventListener() method to listen for keyup event. When it occurs, check the keyCode 's value to see if an Enter key is pressed.
I'm not sure about that...but if you check this link out, it'll show you how to detect whether a user is on a mobile platform or not. you could make your decision based on that?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With