Sign in to follow this  
mrkiwiman

How to check if both mouse buttons are pressed?

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.

Share this post


Link to post
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;
});

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.