1

I'm trying to make a HTML5 game that I've built for web compatible with iOS touches instead of using the left and right keys on the keyboard. What is the best way to access touches in the same way as onkeyup?

Code for the onkeyup:

document.onkeyup = function(e) {
        var key = e.keyCode;

        if (key == 37) {
            dir = "left";
            player.isMovingLeft = false;
        } else if (key == 39) {
            dir = "right";
            player.isMovingRight = false;
        }
    };
  • "same way"? They're completely different things. See [here](http://stackoverflow.com/questions/4755505/how-to-recognize-touch-events-using-jquery-in-safari-for-ipad-is-it-possible) how to capture touches; then in the handler, find out where the touch is. – Amadan Nov 06 '13 at 00:38

0 Answers0