asp.net.ph

Skip Navigation Links

onkeypress Event


Fires when a key is pressed and released over an element.

Syntax

Inline <element onkeypress = "handler" ... >
Script object.onkeypress = handler

Remarks

Bubbles Yes
Cancels Yes
To invoke Press a keyboard key.
Default action Returns a number specifying the Unicode value of the key that was pressed.

Setting event.returnValue=false has no effect on keyboard events used for navigation, on hot keys assigned to the browser, or on system events. The following keys cannot be canceled: TAB, F1 through F12, HOME, END, ESC, DELETE, and the arrow keys.

Event Object Properties

While event handlers in the Document Object Model do not receive parameters directly, the handler can query the event object for data.

Event Object Properties


Example

The onkeypress example shows how to retrieve information from the shiftKey property of the event object.

Sample Code


Applies To

This attribute may be used with most elements.

See Also

onchange, onkeydown, onkeyup


Need a break ?
Suggested Reading

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph.

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