# Detecting the start of a scroll

**URL:** <https://discourse.processing.org/t/detecting-the-start-of-a-scroll/23681>\
**Category:** Development\
**Created:** [September 4, 2020, 4:45pm UTC](https://discourse.processing.org/t/detecting-the-start-of-a-scroll/23681 "2020-09-04T16:45:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jithin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jithin/32/122_2.png) [@Jithin](https://discourse.processing.org/u/Jithin)\
**Post date:** [September 4, 2020, 4:45pm UTC](https://discourse.processing.org/t/detecting-the-start-of-a-scroll/23681/1 "2020-09-04T16:45:35Z")

</div>

Is there any way to detect the start of a scroll in p5? I want just the start of the scroll. The mouseWheel event doesn’t seem to help.

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [September 6, 2020, 4:16am UTC](https://discourse.processing.org/t/detecting-the-start-of-a-scroll/23681/2 "2020-09-06T04:16:46Z")

</div>

I don’t understand exactly what you want; maybe you can detail it a bit more.  
As a start:

```auto
let pos = 25;
let start_time = 0; 

function setup() {
  createCanvas(100, 500) 
}

function draw() {
  var bg = 0;
  if (millis() - start_time > 200) bg = 200;
  background(bg);
  if (pos < 25) pos = 25;
  if (pos > 450) pos = 425;
  rect(25, pos, 50, 50);
}

function mouseWheel(event) {
  pos += event.delta;
  start_time = millis();
}

```
