Detect whether browser has keyboard/arrow keys in web page

前端 未结 8 960
忘了有多久
忘了有多久 2020-12-31 00:21

I have a full-screen game in HTML+JavaScript, which uses the arrow keys as primary controls. This cannot be used on keyboardless Android devices (I haven\'t tested on iOS),

8条回答
  •  长情又很酷
    2020-12-31 00:56

    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.

提交回复
热议问题