simultaneos mouse buttons clicked js

Solutions on MaxInterview for simultaneos mouse buttons clicked js by the best coders in the world

showing results for - "simultaneos mouse buttons clicked js"
Bram
17 Feb 2018
1var leftButtonDown = false;
2var rightButtonDown = false;
3
4$(document).mousedown(function() {
5    if(e.which == 1) {
6        leftButtonDown = true;
7    } else if (e.which == 3) {
8        rightButtonDown = true;
9    }
10});
11
12$(document).mouseup(function() {
13    if(e.which == 1) {
14        leftButtonDown = false;
15    } else if (e.which == 3) {
16        rightButtonDown = false;
17    }
18});
19
20$(document).click(function() {
21    if(leftButtonDown && rightButtonDown) {
22        // left and right buttons are clicked at the same time
23    }
24});