Review
The event object contains three pieces of information!
The attributes and methods in the event object are mainly the mouse and keyboard information.
1. Get the Event Type
Event object property type
2. Obtain buttonsCode
Event object property keycode: Press enter to 13, space to 32, and back to 8
3. Check shift, ALT, and CTRL keys
Whether the event object property is pressed: shiftkey, altkey, ctrlkey
4. Obtain client coordinates
Event object attributes clientx and clienty
5. Get screen coordinates
Event object attributes screenx and screeny
Event Type
Based on the events that trigger the event and the objects that occur, events that occur in the browser can be divided into several types:
I. mouse events
Each mouse event is filled with values for the properties of the following event objects:
1. Coordinate attributes (such as clientx and client)
2. type attributes
3. targer (DOM) or serelement (IE) attributes (target object attributes)
4. shiftkey, ctrlkey, altkey, and metakey (DOM) attributes
5. Button attribute (only in the mouse event)
(Oevent.tar GET | oevent. srcelement ). when the ID logical operator acts on two objects, the first object is not empty, and the first object is returned. Otherwise, the second object is returned, which indicates the ID of the element that caused the event.
Ii. Keyboard Events
Keydown --- occurs when a key is pressed on the keyboard. If you keep pressing a key, it will be triggered continuously.
Keypress --- press a key and generate a character (that is, a key like shit ctrl alt .) When you press the key all the time, it will continue to happen.
Keyup --- release the pressed Button
1. Event attributes
For each keyboard event, the following event attributes are entered:
Keycode attribute (ASC code value of the key position)
Charcode attribute (DOM only)
Target (DOM) and srcelement (IE) attributes
Shiftkey, ctrlkey, altkey, and metakey (DOM) attributes
2. Order
When you press a button for a certain character, an event occurs in the following order:
(1) keydown;
(2) keypress;
(3) keyup;
If you press a non-character button (such as shift) at a time, the event occurs in the following order:
(1) keydown;
(2) keyup;
Iii. HTML events
Onload, unload, resize, scroll and other events.
Iv. Mutation events
The addition and deletion nodes of the Child tree of the document or element are not implemented by any mainstream browsers.