Tip: Do NOT addEventListener to draw()


I don’t know if I have permission to leave tips but as a beginner I made the mistake of assuming an event listener works like keyIsDown(). As it turns out it doesn’t. I struggled so much with my framerate before finally figuring out this simple function adds a new listener to my project every frame. Next time I make sure it’s only run once.
Btw, want to fullscreen your html script in a browser? Add this beauty to your setup()! This is that evil snippet :expressionless:

document.addEventListener("keypress", function() {
    if (keyCode === 70) {
}, false);

thank you very much for share and try to help!

-a- but i try your code ( in setup ) and get error

-b- where on my keyboard is “70”
i recommend to document that kind of things in the code,
and somehow tell the user what operation is possible
( like with a print info to console… or canvas as intro screen )

-c- are you aware of the default function

function keyPressed() {}


fullscreen() does work in CHROME on OS: Raspbian and Win7
but not in Firefox Win7

1 Like

So I think I mainly used eventListener cuz fullscreen() did not seem to work on other sites when uploaded.
And thanks for the tip of the ‘documenting’, I usually don’t leave comments, and that’s somewhat a bad habit of mine.
Also I “commented” your /* function */ and removed the comments at my original one and it seems the eventListener worked flawlessly. I don’t know what might be the issue when you try.