onkeydown attribute
onkeypress attribute
CORE ATTRIBUTE: onkeyup
onkeyup="action"
Available in versions: 4.0
HTML 4.0 tag compatibility: All tags except
applet, base, basefront, bdo, br, font, frame, frameset, head, html, iframe, isindex, meta, param, script, style, title
The
onkeyup
core attribute is an event handler that is associated with releasing up a key on the keyboard while the mouse is inside a selected HTML tag (element). In other words, the key up event occurred while the HTML element was in focus. Whenever you release the key, the script code of the
onkeyup
is executed. This script can also call functions or subroutines which contain code that you want to run when this event occurs. For example, if you only want numbers to be entered, you could capture the value of the key and take appropriate action if a non-numeric key was pressed.
The similar
onkeydown
core attribute is an event handler that is associated with the pressing down of a key, and the
onkeypress
core attribute is an event handler that is associated with the pressing of a key.
In this example, place the mouse inside the
textarea
element and type in a word. Every time you release a key, one line of JavaScript code is executed which causes an alert box to be displayed with a message. Note how the alert comes up after the character is displayed inside the
textarea
.
Code:
<textarea onkeyup="javascript: alert('A key was released up')">
</textarea>
Output:
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information