asp.net.ph

Skip Navigation Links

altKey Property

event Properties   DHTML Events


DOM Level 2 Specification.

Retrieves the current state of the ALT key.

Syntax


HTML N/A
Script [ bAltKeyDown= ] event.altKey

Possible Values


false Indicates that the ALT key is up.
true Indicates that the ALT key is down.

The property is read-only with no default value.

Remarks

This property is used to indicate whether the ALT key was depressed during the firing of the event. On some platforms this key may map to a different key name.

Example

This example tracks whether the Alt, Ctrl, or Shift key returns true ( was pressed ) when an onclick event fires. Click the button with or without any of the keys mentioned and see.

Here's the code for that exercise:

<script language="JavaScript">
<!--
function chkKey ( ) {
   var ctrlKey = document.layers ? event.modifiers &
     Event.CONTROL_MASK : event.ctrlKey;
   var altKey = document.layers ? event.modifiers &
     Event.ALT_MASK : event.altKey;
   var shiftKey = document.layers ? event.modifiers &
     Event.SHIFT_MASK : event.shiftKey;
   alert ( 'Ctrl ' + ctrlKey + ' \nAlt ' + 
     altKey + ' \nShift " + shiftKey );
}
//-->
</script>
Applies To

event

See Also

ctrlKey, shiftKey, Key Capture Routines



>

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note