React onPointerDown Event Last Updated : 24 Jul, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The onPointerDown event in React fires whenever the pointer (mouse) is down i.e. clicked over the tag or element over which the event has been applied. Similar to other events, we have to provide a function which executes the task or process when the event occurs.Syntax:onPointerMove={function}Parameter : function: The function to call whenever mouse click event occurs over the element.Return type:event: An event object containing information about the event like target element and valuesExample 1 : In this example, we implemented an area where the user can click using the mouse and then accordingly displayed whether he/she has performed a left click, right click or middle button click using the "event.button" property of the onPointerDown event. CSS /* App.css */ .App { width: 30vw; margin: auto; text-align: center; color: green; font-size: 23px; } .Shaded { background-color: lightgray; height: 200px; width: 300px; margin: auto; border-radius: 6px; } JavaScript // App.js import { useState } from "react"; import "./App.css" const App = () => { const [click, setClick] = useState(); const function1 = (event) => { if(event.button===0) { setClick("Left Click"); } else if(event.button===1) { setClick("Middle Click") } else if(event.button===2) { setClick("Right Click") } else{ setClick("Undefined Click") } } return ( <div className="App"> <h1>GeeksforGeeks</h1> <h2>Click inside the the shaded area</h2> { click ? <p>{click}</p> : null } <div className="Shaded" onPointerDown={function1}> </div> </div> ); } export default App; Output:Example 2: In this example, we implemented an area where users can click using the mouse. Whenever the mouse click event occures the onPointerDown event gets fired and shows an alert for the same. JavaScript // App.js import "./App.css" const App = () => { const function1 = (event) => { alert("Pointer Down Event Fired!") console.log(event) } return ( <div className="App"> <h1>GeeksforGeeks</h1> <h2>Click inside the the shaded area</h2> <div className="Shaded" onPointerDown={function1}> </div> </div> ); } export default App; Output: Comment More infoAdvertise with us Next Article React onKeyDown Event P prathamgfg Follow Improve Article Tags : Web Technologies ReactJS React Events Similar Reads React onPointerUp Event React onPointerUp event fires when the mouse button is clicked and released and it detects the right, left, or middle click of the mouse. Similar to other events, we have to provide a function that will execute their process.Syntax:onPointerUp={function}Parameter : function that will call once any b 2 min read React onPointerMove Event The onPointerMove event in React fires whenever the cursor moves inside the tag or element where the event has been applied. Similar to other events, the onPointerMove takes a function which defines the process/task which has to be applied.Syntax:onPointerMove={function}Parameter : function: The fun 2 min read React onPointerCancel Event React onPointerCancel fires when a pointer event cancels, like when someone is zoomed into an image and the user suddenly leaves it, which is a part of the onPointerCancel event.Syntax:onPointerCancel={function}Parameter : function that will call once any pointer event cancels.Return type:event: It 2 min read React onKeyDown Event React onKeyDown event occurs on a key press event in a browser. onKeyDown is an updated event in place of onKeyPress. onKeyPress is now deprecated because it does not work for all keys (like CTRL, SHIFT, and ALT) in all browsers, so onKeyDown is a new event listener that is used to detect the key pr 2 min read React onMouseDown Event The onMouseDown event is a native DOM event in React that triggers when the mouse button is pressed down on an element. It is part of a set of mouse events that React and the DOM handle, which includes events like onClick, onMouseUp, onMouseEnter, and others.onMouseDown occurs when any mouse button 5 min read React onMouseEnter Event React onMouseEnter() is an event handler that triggers when the mouse cursor enters the boundaries of an element. It is particularly useful where you want to initiate actions or display information when the user's cursor hovers over an element. It is similar to the HTML DOM onmouseenter event but us 2 min read Like