I asked here (How to detect right click + left click) how to detect when user right click hold it and click on the left button of the mouse
I did like the first answer but its not working as expected,
First in my code I create table and td's, and then I add events to every td like that:
td.setAttribute('onmousedown', "handleMouseDown(event)");
td.setAttribute('onmouseup', "handleMouseUp(event)");
td.setAttribute('onclick', "checkCell(this)");
I dont use addEventListener` because IE < 9.
The two functions to handle the events is:
function handleMouseDown (e) {
if (e.button == 2) rightClicked = true;
}
function handleMouseUp (e) {
if (e.button == 2) rightClicked = false;
}
First its dosent work good, the handleMouseUp
dosen't always set rightClicked
to false
when I was clicked on left button its dosent set rightClicked
to false when I release the right button
so I add to checkCell
if rightClicked
is true
so set it to false.
if (rightClicked) {
rightClicked = false;
Now In the first time I click right click and left its work, but after that its not work anymore unless continue to press left click and after that sometimes it work
Sometimes its dosent work even the first time
My all code in jsfiddle: https://jsfiddle.net/e4pf78zu/ Its dosent work fine there the functions shown in the console as undefined I dont know why can someone fix that for me thanks