mousePressed not working? or something else?

if(!mousePressed){
ellipse(width/2, height/2,100,100);
} else {
rect(width/2, height/2,100,100);
}

error: mousePressed is not defined
I have referenced to p5.js, p5.sound.js and p5.dom.js in my index.html. What is going on here?

In p5.js, it is mouseIsPressed, whereas in Processing it is mousePressed.

Also, format your code using the </> button and make sure you categorise it as p5 not Processing.

1 Like

It works. Thanks. I guess I was watching processing tuts on utube by Shiffman and working on p5js on my laptop. That’s where things got mixed up.