Click to See Complete Forum and Search --> : Key event


scottjsn
05-03-2007, 04:12 PM
I saw some codes:


<body onkeypress="javascript:kp(event);" >
...
<input type="text" onkeydown="return test(event)" />
...


"who" defines the keyword "event"? And what is it (just for key press)?


Thanks

Scott

CrazyMerlin
05-03-2007, 06:25 PM
event is an object defined by the browser.

in IE, the event is automatically available inside an event function (onclick, onchange, etc.), but in firefox you have to pass the evnt object into the function (i.e., it is not global)

the event object serves to provide details about an event and control over the propagation of the event. (i.e., you can cancel and event using the event object. e.g., event.stopPropagation() will stop the event from propagating any further)

Try this link to find more reference:
http://www.w3schools.com/htmldom/dom_obj_event.asp

hope that helps