Updated answer. The following will detect if the left and only the left mouse button is pressed:
function detectLeftButton(evt) {
evt = evt || window.event;
if ("buttons" in evt) {
return evt.buttons == 1;
}
var button = evt.which || evt.button;
return button == 1;
}
For much more information about handling mouse events in JavaScript, try http://unixpapa.com/js/mouse.html