This is described in the link :
Browsers may have different default behaviors associated with various key events. To prevent the default behavior for this event, add "return false" to the end of the method.
In other words, you can simply return false to execute the keyPressed() function:
function setup() { createCanvas(500, 500); } function draw() { } function keyPressed(){ text("here", random(width), random(height)); return false; }
This means that the page should not perform any default behavior. That way you can use return false only for certain keys.
You may also want to add similar return false to other mouse event functions to avoid the case when the user holds the spacebar.
source share