Rising value / mousePressed

I'm looking to raise a value while the mouse is held down. What is the function I'm looking for? My code only raises the value once for each click.

var i = 0;

function setup() {
  createCanvas(200, 200);
  background(222);

}

function draw() {
  noStroke();
  fill(55);
  rect(20,20, 20,i+1);

}

function mousePressed() {

  i++
  print(i);
}
Tagged:

Answers

Sign In or Register to comment.