有没有办法知道来自用户的点击是来自鼠标滚轮还是触控板按钮或触控板按下< / strong>而不是总是假设用户点击鼠标左键单击?
答案 0 :(得分:0)
尝试一下:
var body = document.getElementsByTagName('body')[0];
body.addEventListener('mousedown', function(e) {
if (e.which == 1) {
body.innerHTML = 'click';
}
else if (e.which == 2) {
body.innerHTML = 'middle click';
}
})
<html>
<body>
Click Here
</body>
</html>