Checks if the mouse button specified is pressed.
Some interactive games use the mouse for the user to control the game.
function draw() {
console.log(mouseDown("leftButton"));
}
Simple pencil drawing with mouseDown().
// Simple pencil drawing with mouseDown().
var sprite = createSprite(200, 200, 5, 5);
World.frameRate=60;
function draw() {
sprite.x=World.mouseX;
sprite.y=World.mouseY;
if (mouseDown("leftButton")) drawSprites();
}
mouseDown(button)
| Name | Type | Required? | Description |
|---|---|---|---|
| button | String | The mouse button you want to check, either "leftButton" or "rightButton". |
Boolean true or false.
Found a bug in the documentation? Let us know at documentation@code.org