Detect whether browser has keyboard/arrow keys in web page Detect whether browser has keyboard/arrow keys in web page ios ios

Detect whether browser has keyboard/arrow keys in web page


No need for any user-agent sniffing, config options or any kind of guessing. Just do this:

  1. Have a title screen which says "press to continue".
  2. On click or key press, hide touch controls and start game.
  3. On touch, show touch controls and start game.

You never even needed to mention the option to the user and you auto-detected their preferred control perfectly.


Use feature detection with Modernizr: http://www.modernizr.com/docs/#touch

While this is not a reliable way to check if the user has a keyboard it is definitely reliable to see if the browser is capable of touch.


Instead of trying to guess, make it a config option for the user to choose.