Keyboard Events, event Object
event
-
Sent to event handler when an event occurs.
-
Contains data about the event:
-
type - the type of event.
-
target - the object, document, link, button, etc.
-
which - button pressed for mouse events, key for keyboard events.
Theoretically, use to create number-only fields.
-
modifiers - modifier key pressed (Ctrl, Alt, Shift)
-
data - list of dropped data for drag and drop events.
-
pageX, pageY - the mouse's X and Y position on the page.
-
screenX, screenY - the mouse's X and Y position on the screen.
-
Use X and Y positions for marketing data. How?
Keyboard Events
-
Use with the event object, above.
-
onKeyPress, onKeyDown, onKeyUp, just like mouse events.
-
Use String.fromCharCode(event.which) to find the key pressed.
-
event object works best with Netscape Navigator.
-
Must define a function and dynamically assing the handler to use event
object.
Dynamically Assigned Event Handlers
Home
Internet II: Day 4