# Mouse Buttons

The Wails runtime intercepts mouse clicks to determine whether a frameless window needs resizing or a window needs to be moved. It has been asked how to detect when a mouse click has occurred, because `window.onclick` doesn't report the mouse buttons correctly. The following code shows how to detect mouse clicks:

```javascript
window.addEventListener("mousedown", handleMouseButtonDown);

function handleMouseButtonDown(event) {
  if (event.button === 0) {
    // left mouse button
  } else if (event.button === 1) {
    // middle mouse button
  } else if (event.button === 2) {
    // right mouse button
  } else if (event.button === 3) {
    // back mouse button
  } else if (event.button === 4) {
    // forward mouse button
  } else {
    // other mouse button
  }
}
```

Reference: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
