# Detecting when the mouse enters / exits sketch window

**URL:** <https://discourse.processing.org/t/detecting-when-the-mouse-enters-exits-sketch-window/5798>\
**Category:** Coding Questions\
**Created:** [November 21, 2018, 5:10pm UTC](https://discourse.processing.org/t/detecting-when-the-mouse-enters-exits-sketch-window/5798 "2018-11-21T17:10:26Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [November 21, 2018, 11:17pm UTC](https://discourse.processing.org/t/detecting-when-the-mouse-enters-exits-sketch-window/5798/3 "2018-11-21T23:17:19Z")

</div>

> [@How to tell if the mouse is over the window?](https://discourse.processing.org/t/how-to-tell-if-the-mouse-is-over-the-window/5285/5):
>
> Alright, I added this functionality myself with: public boolean mousePresent = true; public void mouseExited() { mousePresent = false; } public void mouseEntered() { mousePresent = true; }

and

> [@How to tell if the mouse is over the window?](https://discourse.processing.org/t/how-to-tell-if-the-mouse-is-over-the-window/5285/3):
>
> If you add “focused” to your overMyWindow if statement, then it should return only if the sketch is focused.

---

_[View the full topic](https://discourse.processing.org/t/detecting-when-the-mouse-enters-exits-sketch-window/5798)._
