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

onKeyPress

Executes JavaScript code when a KeyPress event occurs; that is, when the user presses or holds down a key.

Event handler for

document, Image, Link, Textarea

Implemented in

Navigator 4.0

Syntax

onKeyPress="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 KeyPress event occurs immediately after a KeyDown event only if onKeyDown returns something other than false. A KeyPress event repeatedly occurs until the user releases the key. You can cancel individual KeyPress events.

See also

onKeyDown, 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