Shift-click: Disabling

JavaScript FAQ | Keyboard & Mouse Events FAQ  

Question: Can I disable the default browser response for Shift-click event?

Answer: In Netscape Navigator 4 or Internet Explorer 4 or newer browsers, you can distinguish the Shift-click event from a simple click, and disable the default response for Shift-click. For example, Shift-click has been disabled on this page. If you use version 4 browser (or newer) under Windows, shift-click on any hyperlink on this page to test that! (In older browsers – or if JavaScript is disabled in the browser – the user would still get the default response.)

To disable Shift-click, insert the following code in your page's <HEAD> section:

<script language="JavaScript">
function mouseDown(e) {
 var shiftPressed=0;
 var evt = e?e:window.event;
 if (parseInt(navigator.appVersion)>3) {
  if (document.layers && navigator.appName=="Netscape")
  else shiftPressed=evt.shiftKey;
  if (shiftPressed) {
   alert ('Shift-click is disabled.')
   return false;
 return true;
if (parseInt(navigator.appVersion)>3) {
 document.onmousedown = mouseDown;
 if (document.layers && navigator.appName=="Netscape") 
See also:
  • Left vs. Right vs. Middle Mouse Button
  • Copyright © 1999-2011,