spacer
Yehuda Shiran January 6, 2001
Detecting the ALT Key
Tips: January 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

The e object holds a lot of information about the Netscape 6 event. The altKey property, for example, reveals whether the ALT key was in a pressed position during the event firing. The following statement prints true when the ALT key is pressed, and false otherwise:

window.status = e.altKey;
The status window is shown on the bottom left corner of Netscape 6 window. Notice that you have to pass the e object as a parameter to those functions which reference it. In the following example, we pass the e object as a parameter to colorItYellow() and colorItTan():

<DIV ID="demoDiv" STYLE="position:relative; left:100px; top:20px; width:120px; 
height:25px; color:blue; background-color:yellow;">Mouse over me!</DIV>
<SCRIPT LANGUAGE="JavaScript">
<!--
var demoObj;

function init() {
  demoObj = document.getElementById("demoDiv");
  demoObj.addEventListener("mouseover", colorItTan, false);
  demoObj.addEventListener("mouseout", colorItYellow, false);
}

function colorItTan(e) {
  demoObj.style.backgroundColor = "tan";
  window.status = e.altKey;
}

function colorItYellow(e) {
  demoObj.style.backgroundColor = "yellow";
  window.status = e.altKey;
}

onload = init; 
// -->
</SCRIPT>
Get on Netscape 6 browser and play with this demo.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint