JavaScript Examples


onKeyUp‚ onKeyDown‚ & onKeyPress

Note: While Internet Explorer allowed buttons to be triggered by these events‚ Netscape didn’t. Internet Explorer also allowed the use of special characters in the label‚ while Netscape didn’t. This is a workaround.



The KeyDown event is triggered when the user presses a Key.

The KeyUp event is triggered when the user releases a Key.

The KeyPress event is triggered when the user presses & releases a Key.

The button label is stored in the document.formname.fieldname.value property where the formname is replaced by name defined in the <form> tag‚ and the fieldname is replaced by name defined in the <input> tag for a particular button. The value property can be replaced by the value defined in the <input> tag or assigned in the function.

The button label function uses an if/else statement to determine which button label to change.


Created by: R. Hinton