DEV Community

Simon Halimonov
Simon Halimonov

Posted on

💡 TIL: Listen for a right click with "contextmenu"

TIL: If you want to listen for a right click in JavaScript you can use the contextmenu event.

Example with .addEventListener:

btn.addEventListener(`contextmenu`, ()=>{})

In React with JSX:

<Button onContextMenu={()=>{}}/>

I always used to check some key code or another event property ... 🤣

Top comments (0)