# Detecting mouse clicks that are outside the canvas?

**URL:** https://discourse.processing.org/t/detecting-mouse-clicks-that-are-outside-the-canvas/22335
**Category:** Coding Questions
**Created:** [July 2, 2020, 8:53pm UTC](https://discourse.processing.org/t/detecting-mouse-clicks-that-are-outside-the-canvas/22335 "2020-07-02T20:53:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![qewer3322](https://avatars.discourse-cdn.com/v4/letter/q/e19adc/32.png) [@qewer3322](https://discourse.processing.org/u/qewer3322)
#### Post date: [July 2, 2020, 8:53pm UTC](https://discourse.processing.org/t/detecting-mouse-clicks-that-are-outside-the-canvas/22335/1 "2020-07-02T20:53:54Z")

</div>

I have researched all that I could for this, there is not many stuff to see. I read somewhere that this is not possible but I feel like it is. Does anyone know?

Like when I do

```auto
void mousePressed() {
}

```

that only works when clicked inside the canvas. I want it to also work when clicked outside the canvas.

---

<div class="post-metadata">

### Author: ![slow\_izzm](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/slow_izzm/32/5637_2.png) [@slow\_izzm](https://discourse.processing.org/u/slow_izzm)
#### Post date: [July 2, 2020, 9:18pm UTC](https://discourse.processing.org/t/detecting-mouse-clicks-that-are-outside-the-canvas/22335/2 "2020-07-02T21:18:30Z")

</div>

> <https://github.com/processing/p5.js/issues/1437#issuecomment-222509577>
>
> I'm planning to implement some game exemple for my pupils with p5js. I've found a strange issue. mouse events (clicks) outside...

---

<div class="post-metadata">

### Author: ![qewer3322](https://avatars.discourse-cdn.com/v4/letter/q/e19adc/32.png) [@qewer3322](https://discourse.processing.org/u/qewer3322)
#### Post date: [July 2, 2020, 9:21pm UTC](https://discourse.processing.org/t/detecting-mouse-clicks-that-are-outside-the-canvas/22335/3 "2020-07-02T21:21:19Z")

</div>

I have seen that, that is not exactly what I need. That is for p5.js and it is for ignoring the clicks outside the window.

---

<div class="post-metadata">

### Author: ![slow\_izzm](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/slow_izzm/32/5637_2.png) [@slow\_izzm](https://discourse.processing.org/u/slow_izzm)
#### Post date: [July 2, 2020, 9:27pm UTC](https://discourse.processing.org/t/detecting-mouse-clicks-that-are-outside-the-canvas/22335/4 "2020-07-02T21:27:40Z")

</div>

Oh … sorry, I don’t think it’s possible in Java.

---

<div class="post-metadata">

### Author: ![SouSageYa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sousageya/32/9819_2.png) [@SouSageYa](https://discourse.processing.org/u/SouSageYa)
#### Post date: [July 2, 2020, 9:37pm UTC](https://discourse.processing.org/t/detecting-mouse-clicks-that-are-outside-the-canvas/22335/5 "2020-07-02T21:37:14Z")

</div>

I dont think you can do it in Java version its broken
