Detect Right Click + Left Click Not Working
Solution 1:
This doesn't work for a couple of reasons.
First of all you are setting the event listeners for each cell in a very weird way, not to mention you are doing it wrong.
td.setAttribute('onmousedown', "handleMouseDown(event)");
Why didn't you simply do
td.onmousedown = handleMouseDown;Also, you are doing handleMouseDown(event), which I am pretty sure is wrong.
In general, please don't add your event handlers like this.
I dont use addEventListener` because IE < 9.
IE9 and below don't support addEventListener but they do support attachEvent which is probably better than doing .on<EventName> = function(){}, or what you are doing there currently.
Moreover you can even simulate addEventListener in these browsers as well. Simply use this polyfill here, and in general read about addEventListener
the handleMouseUp dosen't always set rightClicked to false when I was clicked on left button
rightClicked is supposed to become false only when you release the right button, so that works as expected.
its dosent set rightClicked to false when I release the right button
Well, based on the code you provided, that's impossible. The code pretty clearly says
if (e.button == 2) rightClicked = false;
so I add to checkCell if rightClicked is true so set it to false.
This was probably not needed. Resolve your other issues first and then see if you really need to do this.
Post a Comment for "Detect Right Click + Left Click Not Working"