Certainly! Here's a cheat sheet for JavaScript events:
Mouse Events:
click
: Occurs when the element is clicked.dblclick
: Occurs when the element is double-clicked.mouseover
: Occurs when the mouse pointer is moved onto the element.mouseout
: Occurs when the mouse pointer is moved off the element.mousedown
: Occurs when the mouse button is pressed down on the element.mouseup
: Occurs when the mouse button is released on the element.
Keyboard Events:
keydown
: Occurs when a key is pressed down.keyup
: Occurs when a key is released.keypress
: Occurs when a key is pressed and released.
Form Events:
submit
: Occurs when a form is submitted.input
: Occurs when the value of an input field changes.change
: Occurs when the value of a form element changes (e.g., select, checkbox).
Window Events:
load
: Occurs when the document and its resources have finished loading.resize
: Occurs when the browser window is resized.scroll
: Occurs when the user scrolls the document.
Touch Events (for mobile devices):
touchstart
: Occurs when a touch point is placed on the touchscreen.touchmove
: Occurs when a touch point is moved along the touchscreen.touchend
: Occurs when a touch point is removed from the touchscreen.
Event Handling:
element.addEventListener('event', eventHandler)
: Attaches an event handler function to the element.element.removeEventListener('event', eventHandler)
: Removes an event handler function from the element.event.preventDefault()
: Prevents the default behavior of the event.event.stopPropagation()
: Stops the event from bubbling up to parent elements.
Remember that you can replace 'event'
with the specific event name, and eventHandler
should be the function that will be called when the event occurs.
This is a basic overview of JavaScript events. The events available in your specific environment may vary, so it's always a good idea to refer to the official documentation for more details and examples.