Checks if the mouse button specified was pressed.
Some interactive games use the mouse for the user to control the game. mouseWentDown() generates a single true value when the mouse button is pressed down, no matter how long the button is pressed. Use mouseDown()
to continually check if the button is pressed.
function draw() { console.log(mouseWentDown("leftButton")); }
Change the background by clicking a mouse button.
// Change the background by clicking a mouse button. function draw() { if (mouseWentDown("rightButton")) background("black"); if (mouseWentDown("leftButton")) background("white"); }
mouseWentDown(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