I'm writing a minesweeper clone in javascript and since most browsers won't let you capture right clicks I need some other way to flag a tile.
One way I am considering is control click. I found this code on the web and it seems to work for Internet Explorer
Code:
...
if (parseInt(navigator.appVersion) > 3) {
document.onmousedown = mouseDown;
if (navigator.appName == "Netscape")
document.captureEvents(Event.MOUSEDOWN);
}
...
/* this only works for IE at the moment */
function mouseDown(e) {
if (parseInt(navigator.appVersion)>3) {
if (navigator.appName == "Netscape") {
var mString = (e.modifiers+32).toString(2).substring(3,6);
shiftPressed = (mString.charAt(0)=="1");
ctrlPressed = (mString.charAt(1)=="1");
altPressed = (mString.charAt(2)=="1");
} else {
shiftPressed= event.shiftKey;
altPressed = event.altKey;
ctrlPressed = event.ctrlKey;
}
}
return true;
}
but as you can see from my implementation at
http://users.cs.cf.ac.uk/B.A.Collins
it just doesn't work in any browser other than IE.
Are there any other ways of capturing a control-click that aren't about 30 years old? Also I probably should've posted this in tech.