[Contents] [Previous] [Next] [Index]

onKeyDown

Executes JavaScript code when a KeyDown event occurs; that is, when the user depresses a key.

Event handler for

document, Image, Link, Textarea

Implemented in

Navigator 4.0

Syntax

onKeyDown="handlerText"

Parameters

handlerText
JavaScript code or a call to a JavaScript function.

Event properties used

type
Indicates the type of event.

target
Indicates the object to which the event was originally sent.

layerX, layerY,
pageX, pageY,
screenX, screenY
For an event over a window, these represent the cursor location at the time the event occurred. For an event over a form, they represent the position of the form element.

which
Represents the ASCII value of the key pressed. To get the actual letter, number, or symbol of the pressed key, use the String.fromCharCode method. To set this property when the ASCII value is unknown, use the String.charCodeAt method.

modifiers
Contains the list of modifier keys held down when the event occurred.

Description

A KeyDown event always occurs before a KeyPress event. If onKeyDown returns false, no KeyPress events occur. This prevents KeyPress events occurring due to the user holding down a key.

See also

onKeyPress, onKeyUp

For general information on event handlers, see "General Information about Events".

For information about the event object, see event.


[Contents] [Previous] [Next] [Index]

Last Updated: 10/31/97 16:34:02


Copyright � 1997 Netscape Communications Corporation