|Property/method value type:||Boolean primitive|
|HTML syntax:||<A onKeyDown="..."> <AREA onKeyDown="..."> <BODY onKeyDown="..."> <HTMLTag onKeyDown="..."> <IMG onKeyDown="..."> <INPUT onKeyDown="...">|
|Argument list:||aHandler||A reference to a function object to handle the event|
As the key is pressed down, this event is triggered. If you return the value true, the event will be passed to the browser for further processing. Returning false inhibits this action and discards the message.
In Netscape, the key code of the key that triggered the event is available in the which property of the Event object that is passed to the event handler as an argument. The equivalent value in MSIE is available in the keyCode property of the event object referenced by the window.event property.
The key value is the Unicode character code point value, which is a numeric value. This may need to be converted to a character if you want to display it. You can do that with the String.fromCharCode() static method, which will create a one character string for you.
You may need to determine whether any of the modifier keys were pressed. In Netscape, you retrieve a bitmask value from the modifiers property of the Event object. This can then be masked against the various bit flags available as static properties of the Event class.
In MSIE, modifier keys are available with a set of properties, which return the state of each modifier key individually.
In MSIE, you can modify the value of the key that is passed back to the browser by storing a different Unicode code point value in the returnValue property of the Event object.
To use key-codes and modifier keys in a portable way, you will need to implement some browser-specific support and then call an appropriate routine according to the browser the script is executing in.
This is not supported on the WebTV platform.
|See also:||Element object, Event, Event handler, Event model, Event names, Event object, Event.altKey, Event.ctrlKey, Event.keyCode, Event.modifiers, Event.returnValue, Event.shiftKey, Event.which, Handler, JellyScript, Keyboard events, onKeyPress, onKeyUp, Semantic event, String.fromCharCode(), TEXTAREA object, TextCell object|