Jump to content

How to check if both mouse buttons are pressed?


mrkiwiman
 Share

Recommended Posts

This is my code right now to check if left or right mouse button is down:

// Left button down
app.stage.on("mousedown", function() {
  // code...
});

// Right button down
app.stage.on("rightdown", function() {
  // code...
});

But it doesn't seems to be possible that both events happen at the same time.

How would I check if both mouse buttons are pressed? Left and right.

Link to comment
Share on other sites

I would code it as follows:

var rightDown = false;

// Left button down
app.stage.on("mousedown", function() {
  if (rightDown){
    // both buttons are down
    // only need this functionality of course on one button
  }
});

// Right button down
app.stage.on("rightdown", function() {
  rightDown = true;
});

// Right button up
app.stage.on("rightup", function() {
  rightDown = false;
});

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...