Kartika Posted April 2, 2014 Share Posted April 2, 2014 Hi.I am trying to make my canvas based javascript game work for mobile. I would like to know how to translate 'click' event to touch based event. tap is given as an alternative but I am unable to find the event name . documentation just gives touchstart,touchmove and touch end. Will I have to use a package like jquery mobile? TIA Kartika Quote Link to comment Share on other sites More sharing options...
kuuuurija Posted April 3, 2014 Share Posted April 3, 2014 to simulate "tap", you need to make use of both "touchstart" and "touchend" events.var isTouchStart = false;document.addEventListener("touchstart", function(event){ isTouchStart = true;}, false);document.addEventListener("touchend", function(event){ if(isTouchStart == true) { isTouchStart = false; console.log("tap was success!"); }}, false);something similar to above. Kartika 1 Quote Link to comment Share on other sites More sharing options...
Kartika Posted April 4, 2014 Author Share Posted April 4, 2014 Hi,Thanks for your reply. I am using touchstart and touchend for different purpose. jquery mobile actually uses a timer. I guess that would also be required. kartika to simulate "tap", you need to make use of both "touchstart" and "touchend" events.var isTouchStart = false;document.addEventListener("touchstart", function(event){ isTouchStart = true;}, false);document.addEventListener("touchend", function(event){ if(isTouchStart == true) { isTouchStart = false; console.log("tap was success!"); }}, false);something similar to above. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.