# Way to check if draw() is currently looping?

**URL:** https://discourse.processing.org/t/way-to-check-if-draw-is-currently-looping/16946
**Category:** Coding Questions
**Created:** [January 7, 2020, 11:52pm UTC](https://discourse.processing.org/t/way-to-check-if-draw-is-currently-looping/16946 "2020-01-07T23:52:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![maayan](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@maayan](https://discourse.processing.org/u/maayan)
#### Post date: [January 7, 2020, 11:52pm UTC](https://discourse.processing.org/t/way-to-check-if-draw-is-currently-looping/16946/1 "2020-01-07T23:52:11Z")

</div>

Is there any way to check if draw() is currently looping (ie if loop/noLoop was called)? There doesn’t seem to be a way to do this in the p5 library so is there some way to check under the hood?

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [January 8, 2020, 12:22am UTC](https://discourse.processing.org/t/way-to-check-if-draw-is-currently-looping/16946/2 "2020-01-08T00:22:11Z")

</div>

> [@maayan](#):
>
> … so is there some way to check under the hood?

This is the source code for the p5::**noLoop()** method:

> **[reference | p5.js](https://p5js.org/reference/#/p5/noLoop)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

> <https://github.com/processing/p5.js/blob/0.10.2/src/core/structure.js#L69-L71>

And this is for the p5::**loop()** method:

> **[reference | p5.js](https://p5js.org/reference/#/p5/loop)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

> <https://github.com/processing/p5.js/blob/0.10.2/src/core/structure.js#L111-L118>

So we just need to access the “private” undocumented property p5::_\_loop_:  
`const isLooping = _loop;`

---

<div class="post-metadata">

### Author: ![maayan](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@maayan](https://discourse.processing.org/u/maayan)
#### Post date: [January 8, 2020, 4:12am UTC](https://discourse.processing.org/t/way-to-check-if-draw-is-currently-looping/16946/3 "2020-01-08T04:12:08Z")

</div>

Thanks for getting back to quickly GoToLoop! I was having trouble with\_looping for some reason and just ended up using my own variable to keep track of it. I appreciate you helping out though 🙂
