The
object is a subsidiary object of event
, but we won't spend too much time covering it here. Instead, we'll wait for chapter 5 when we talk more about scripting, as this is when the properties will come in to use – in conjunction with the events that have been triggered by the browser and identified in the scripting code. window
The objects we've talked about so far generally have reflected concrete parts of the window or browser. Many of them can't even be changed, and they're all around at all times for querying if not modifying. The
object, in contrast, is a much more ephemeral beast. It furnishes specific information about the event last fired by the browser and can and will be very different from one instant to the next. The different properties of event tell things like the state of the Ctrl, Alt, and Shift keys when the event was first fired, whether or not any mouse buttons were pressed, and so on.event
Property | Value |
|
The state of the Alt key |
|
The mouse button(s), if any, that was (were) pressed to fire the event |
|
Stops the current event from bubbling up the hierarchy |
|
The x coordinate of an element, excluding borders, margins, scrollbars etc |
|
The y coordinate of an element, excluding borders, margins, scrollbars etc |
|
The state of the Ctrl key |
|
Specifies the element being moved from (for and events) |
|
ASCII code of the key being pressed (if a key has been pressed) |
|
the x coordinate of the mouse pointer when an event occurs, relative to the containing element |
|
The y coordinate of the mouse pointer when an event occurs, relative to the containing element |
|
Sets the return value for the event |
|
The x coordinate of the mouse pointer when an event occurs, relative to the screen |
|
The y coordinate of the mouse pointer when an event occurs, relative to the screen |
|
The state of the Shift key |
|
The deepest element that the event occurred over |
|
Specifies the filter that caused the element to produce an event |
|
Specifies the element being moved to (for and events) |
|
Returns the name of the event as a string, without the prefix, such as instead of
|
|
The horizontal position of the mouse in window coordinates (pixels) |
|
The vertical position of the mouse in window coordinates (pixels) |
This object is extremely useful when we write script code and perform exotic sounding things like 'event-bubbling', however we'll avoid discussing any of the properties until chapter 5 of this book, as you'll need to understand how events can be caught by your scripting code first.