`addEventListener` in JavaScript allows you to listen for a wide range of events. Here’s a list of some common events that you can attach listeners to:
Mouse Events:
1. `click` – Mouse click.
2. `dblclick` – Double click.
3. `mousedown` – Mouse button is pressed.
4. `mouseup` – Mouse button is released.
5. `mousemove` – Mouse pointer moves.
6. `mouseover` – Mouse pointer enters an element.
7. `mouseout` – Mouse pointer leaves an element.
8. `mouseenter` – Similar to `mouseover`, but doesn’t bubble.
9. `mouseleave` – Similar to `mouseout`, but doesn’t bubble.
10. `contextmenu` – Right-click event.
Keyboard Events:
11. `keydown` – Key is pressed down.
12. `keyup` – Key is released.
13. `keypress` – Character key is pressed.
Form Events:
14. `submit` – A form is submitted.
15. `reset` – A form is reset.
16. `focus` – Element receives focus.
17. `blur` – Element loses focus.
18. `change` – Value of an input element changes.
19. `input` – Text input changes (modern browsers).
20. `select` – Text in an input or textarea is selected.
Window and Document Events:
21. `load` – Window or frame finishes loading.
22. `unload` – Window or frame is unloaded.
23. `resize` – Window or frame is resized.
24. `scroll` – Document is scrolled.
Touch Events (for mobile devices):
25. `touchstart` – A touch event starts.
26. `touchmove` – Touch point moves.
27. `touchend` – Touch event ends.
Drag and Drop Events:
28. `dragstart` – Drag operation starts.
29. `dragend` – Drag operation ends.
30. `dragenter` – Element is dragged into a target.
31. `dragover` – Element is dragged over a target.
32. `dragleave` – Element is dragged out of a target.
33. `drop` – Element is dropped onto a target.
Media Events:
34. `play` – Media starts playing.
35. `pause` – Media is paused.
36. `ended` – Media playback ends.
Clipboard Events:
37. `copy` – Copy operation is triggered.
38. `cut` – Cut operation is triggered.
39. `paste` – Paste operation is triggered.
Miscellaneous Events:
40. `error` – Error occurs.
41. `loadstart` – Resource starts loading (used for audio and video elements).
42. `loadeddata` – Media data is loaded.
43. `canplay` – Media can start playing.
44. `readystatechange` – State of the document (used for `document`).
These are just some of the common events you can listen for. There are more specialized events and events related to specific elements and libraries. The exact set of events available may vary between browsers and JavaScript frameworks. You can find the full list of events in the documentation for the specific object or element you are working with.
Did I miss any? Let me know.
Recent Comments