且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在javascript中检测touchstart上的两个手指?

更新时间:2023-11-18 07:56:28

触摸事件包含一个属性,称为触及,其中包含所有可用的触摸点。您可以在MDN上阅读有关TouchEvents的更多信息,请访问

The touch events contain a property, called touches, which contains all the touch points available. You can read more about TouchEvents on MDN.

在您的情况下,您需要检查 touches 属性的长度:

In your case, you would need to check the length of the touches property:

$someElement.on('touchstart', function (e) {
    if (e.touches.length > 1)
        // ... do what you like here
});