Skip to content

Paras-jindal1604/JavaScript---Events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฏ JavaScript Events: Keyboard, Mouse & the Event Object

Welcome to the JavaScript Events ! This repository helps you understand and practice handling events in JavaScriptโ€”especially keyboard and mouse events. Youโ€™ll also explore the powerful event object and its most useful properties.


๐Ÿ“š Table of Contents

  • ๐Ÿ“Œ Introduction
  • ๐Ÿ–ฑ๏ธ Mouse Events
  • โŒจ๏ธ Keyboard Events
  • ๐Ÿ“ฆ The event Object
    • event.target
    • event.key
    • event.clientX / event.clientY

๐Ÿ“Œ Introduction

In JavaScript, events are actions that occur in the browserโ€”like clicking a button, pressing a key, or moving the mouse. We can use event listeners to detect these actions and run custom code in response.


๐Ÿ–ฑ๏ธ Mouse Events

Commonly used mouse events in JavaScript:

  • click: User clicks an element
  • dblclick: User double-clicks
  • mousedown: Mouse button is pressed
  • mouseup: Mouse button is released
  • mousemove: Mouse pointer moves
  • mouseenter / mouseleave: Pointer enters or leaves an element

โŒจ๏ธ Keyboard Events

Keyboard events allow us to respond to user key presses:

  • keydown: Triggered when a key is pressed
  • keyup: Triggered when a key is released
  • keypress: (Deprecated) Avoid using in modern code

๐Ÿ“ฆ The event Object

When an event occurs, JavaScript creates an event object containing useful info about the event.

๐Ÿ”น event.target

  • Refers to the element that triggered the event.

๐Ÿ”น event.key

  • Returns the actual key the user pressed (like "a", "Enter", "1").

๐Ÿ”น event.clientX / event.clientY

  • clientX: X-coordinate (horizontal) of the mouse relative to the viewport

  • clientY: Y-coordinate (vertical) of the mouse relative to the viewport


๐Ÿ‘จโ€๐Ÿ’ป Author

Documented by Paras Jindal as part of a structured roadmap to mastering JavaScript and web development fundamentals.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published