2

I currently have this for my touch events:

if( 'ontouchstart' in document.body) {
    usevkeys = true;
    canvas.addEventListener("touchstart",function(e) {evt.call(this,e);},false);
    canvas.addEventListener("touchend",function(e) {evt.call(this,e);},false);
    canvas.addEventListener("touchmove",function(e) {evt.call(this,e);},false);
}
else {
    canvas.addEventListener("mousemove",function(e) {evt.call(this,e);},false);
    canvas.addEventListener("click",function(e) {evt.call(this,e);},false);
}

This works fine on my laptop, and on my phone. However, I have to wonder, how would this react in an environment that has both a touchscreen and a normal mouse? Does the mouse trigger touch events, like the phone triggers mousemove events?

What can I do to make sure it works?

4

1 回答 1

0

a 在touchstart触发后立即触发click事件touchend(-> 如果尚未取消)。所以你应该删除 else 子句,应该没问题!

微软在 IE10 中的触摸事件采用了不同的方式,将所有指针设备协调为指针和手势事件,您可以在其中检查它是否被鼠标、笔或手指触发 - 或者将来可能是 kinect 样式的设备.

于 2013-05-14T21:22:47.427 回答