How to detect right click + left click

后端 未结 6 712
感动是毒
感动是毒 2021-01-13 19:22

I am building a game

And I need to do something when the user clicks on the right mouse button, holds it and then presses the left button

6条回答
  •  灰色年华
    2021-01-13 20:01

    for right click use oncontextmenu and for left just set up click , just disable their default behaviours if you want too, ex:

    var left = 0,
      right = 0;
    
    document.onclick = function() {
      console.log(++left);
      return false;
    };
    
    document.oncontextmenu = function() {
      console.log(++right);
      return false;
    };

提交回复
热议问题