ManticMoo.COM -> Jeff's Articles -> Web Hacks -> Capturing CTRL-key combinations with Javascript

Capturing CTRL-key combinations with Javascript

by Jeffrey P. Bigham

The following code will allow you to capture CTRL-key combinations in both Internet Explorer and Netscape variations.


if (parseInt(navigator.appVersion)>3) {

  var evt = (navigator.appName == "Netscape" ? my_event : window.event);

  ctrlPressed = evt.ctrlKey;

  if (ctrlPressed) 
    alert ("Key " +  with the following keys:\n" ctrlPressed  ? "Ctrl " :"")
	   )
}

ManticMoo.COM -> Jeff's Articles -> Web Hacks -> Capturing CTRL-key combinations with Javascript