Detect whether browser has keyboard/arrow keys in web page

前端 未结 8 949
忘了有多久
忘了有多久 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 01:10

    You could use javascript to find out the height of the windows view port and then us an if statement saying:

    if ($(window).height() <= "960")) {
        //Your code to display keyboard controls
        //P.S. 960 is height of iPhone 4+ screen
    }
    

    Edit: Left out ) at end of $(window).height() <= "960"

提交回复
热议问题