# Beginners

**URL:** https://discourse.processing.org/c/p5js/p5js-beginners/16.md

[Latest](https://discourse.processing.org/latest.md) · [Categories](https://discourse.processing.org/categories.md) · [Tags](https://discourse.processing.org/tags.md)

---

## [About the p5.js / Beginners category](https://discourse.processing.org/t/about-the-p5-js-beginners-category/27)

<div class="topic-metadata">

**Author:** [@ProcessingOrg](https://discourse.processing.org/u/ProcessingOrg)\
**Replies:** 0\
**Last updated:** [May 12, 2018, 4:54am UTC](https://discourse.processing.org/t/about-the-p5-js-beginners-category/27 "2018-05-12T04:54:59Z")

</div>

Discussions and questions for people starting out with p5.js

---

## [Accessing width and height variables much slower in P5 Ver 2.0 compared to Ver 1.0](https://discourse.processing.org/t/accessing-width-and-height-variables-much-slower-in-p5-ver-2-0-compared-to-ver-1-0/49325)

<div class="topic-metadata">

**Author:** [@ozjerry](https://discourse.processing.org/u/ozjerry)\
**Replies:** 21\
**Last updated:** [September 11, 2026, 12:14pm UTC](https://discourse.processing.org/t/accessing-width-and-height-variables-much-slower-in-p5-ver-2-0-compared-to-ver-1-0/49325 "2026-09-11T12:14:03Z")

</div>

Problem: There seems to be a big discrepancy in performance I recently came back to P5 after not having used it for a few years. I’m just coding. I grabbed the latest version (2.3.2) and wrote a quick game of life prog…

---

## [I need help plz thanks if you do im a beginner sorry](https://discourse.processing.org/t/i-need-help-plz-thanks-if-you-do-im-a-beginner-sorry/49230)

<div class="topic-metadata">

**Author:** [@chuudtaco](https://discourse.processing.org/u/chuudtaco)\
**Replies:** 2\
**Last updated:** [August 21, 2026, 5:41am UTC](https://discourse.processing.org/t/i-need-help-plz-thanks-if-you-do-im-a-beginner-sorry/49230 "2026-08-21T05:41:25Z")

</div>

hi I don’t know why my keyPressed isn’t working, I copied and pasted references and they don’t work either, i’m not sure if it’s a me problem. https://editor.p5js.org/chuud/sketches/FtKfFDUL5 sorry if i used wrong form…

---

## [Making keyPressed() doesn't seem to work in p5.js as it did in Java, how can I make it work or replace it?](https://discourse.processing.org/t/making-keypressed-doesnt-seem-to-work-in-p5-js-as-it-did-in-java-how-can-i-make-it-work-or-replace-it/49153)

<div class="topic-metadata">

**Author:** [@superPengato](https://discourse.processing.org/u/superPengato)\
**Replies:** 4\
**Last updated:** [August 13, 2026, 6:13pm UTC](https://discourse.processing.org/t/making-keypressed-doesnt-seem-to-work-in-p5-js-as-it-did-in-java-how-can-i-make-it-work-or-replace-it/49153 "2026-08-13T18:13:58Z")

</div>

Hello ! I have a game that I created years ago as a school project in processing Java, and now I’ve been trying to port it to js so that I can put it on a webpage. I am not experienced in JS. I did a lot of it with ava…

---

## [Adding id to Input and Select](https://discourse.processing.org/t/adding-id-to-input-and-select/48549)

<div class="topic-metadata">

**Author:** [@4everJang](https://discourse.processing.org/u/4everJang)\
**Replies:** 3\
**Last updated:** [June 30, 2026, 10:07am UTC](https://discourse.processing.org/t/adding-id-to-input-and-select/48549 "2026-06-30T10:07:08Z")

</div>

Trying to programmatically change inputs (and selected options) but there is no @id on any of the input and select fields created with createInput and createSelect. Is this possible at all or do I have to create my own i…

---

## [Where are the Javascript classes before I use them?](https://discourse.processing.org/t/where-are-the-javascript-classes-before-i-use-them/48819)

<div class="topic-metadata">

**Author:** [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Replies:** 2\
**Last updated:** [June 15, 2026, 9:43pm UTC](https://discourse.processing.org/t/where-are-the-javascript-classes-before-i-use-them/48819 "2026-06-15T21:43:02Z")

</div>

Hello, Now that I’ve started using P5js and therefore Javascript, I’m curious about how it works internally.:slight\_smile: So, an object in javascript is likely to be permanently erased from memory when there is nothin…

---

## [Control variables and method created while a program is running](https://discourse.processing.org/t/control-variables-and-method-created-while-a-program-is-running/47995)

<div class="topic-metadata">

**Author:** [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Replies:** 28\
**Last updated:** [March 31, 2026, 6:19am UTC](https://discourse.processing.org/t/control-variables-and-method-created-while-a-program-is-running/47995 "2026-03-31T06:19:15Z")

</div>

Another weird question ! lol In java, it is impossible to create a variable or a method outside the class declaration. But in Javascript, it is quite possible. I just spent a lot of time looking for the origin of a ver…

---

## [mouseClicked(), mousePressed()... keyPressed(), keyReleased()... are they parallel?](https://discourse.processing.org/t/mouseclicked-mousepressed-keypressed-keyreleased-are-they-parallel/47898)

<div class="topic-metadata">

**Author:** [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Replies:** 9\
**Last updated:** [February 20, 2026, 8:14am UTC](https://discourse.processing.org/t/mouseclicked-mousepressed-keypressed-keyreleased-are-they-parallel/47898 "2026-02-20T08:14:00Z")

</div>

Hello, My question is When are theses functions processed / what is in draw() ? (is it the same thing in Processing ?) Is there some sort of parallelism (multiple threads) or not ? (I guess not) I wonder ! thank you …

---

## [MouseOver function](https://discourse.processing.org/t/mouseover-function/47762)

<div class="topic-metadata">

**Author:** [@Neo\_Wang](https://discourse.processing.org/u/Neo_Wang)\
**Replies:** 4\
**Last updated:** [January 21, 2026, 5:19pm UTC](https://discourse.processing.org/t/mouseover-function/47762 "2026-01-21T17:19:06Z")

</div>

Can mouseOver function detect if the mouse is on the shape drawn on the canvas. in the reference’s example, it seems it can only detect whether the mouse has entered the element, what about shapes. if it can, how to use …

---

## [Can't seem to draw in the setup function (beginner question)](https://discourse.processing.org/t/cant-seem-to-draw-in-the-setup-function-beginner-question/47555)

<div class="topic-metadata">

**Author:** [@pimath](https://discourse.processing.org/u/pimath)\
**Replies:** 5\
**Last updated:** [November 23, 2025, 9:28pm UTC](https://discourse.processing.org/t/cant-seem-to-draw-in-the-setup-function-beginner-question/47555 "2025-11-23T21:28:32Z")

</div>

I’m using the p5.js web editor and can’t seem to get anything drawn to the screen using setup(). It does work in draw() though. Oddly I tested copy/pasting code in from the setup() reference page and it works when I cop…

---

## [Using HTML button element to change a variable in the Javascript](https://discourse.processing.org/t/using-html-button-element-to-change-a-variable-in-the-javascript/47557)

<div class="topic-metadata">

**Author:** [@telstartelstar](https://discourse.processing.org/u/telstartelstar)\
**Replies:** 3\
**Last updated:** [November 23, 2025, 1:55am UTC](https://discourse.processing.org/t/using-html-button-element-to-change-a-variable-in-the-javascript/47557 "2025-11-23T01:55:24Z")

</div>

Hi again! For another part of my project I’m trying to figure out how to use a element in the HTML of my sketch to change a set variable in my Javascript. In specific I’m using it to change the background image variabl…

---

## [Porting p5js code to another program](https://discourse.processing.org/t/porting-p5js-code-to-another-program/47507)

<div class="topic-metadata">

**Author:** [@telstartelstar](https://discourse.processing.org/u/telstartelstar)\
**Replies:** 9\
**Last updated:** [November 22, 2025, 9:29pm UTC](https://discourse.processing.org/t/porting-p5js-code-to-another-program/47507 "2025-11-22T21:29:58Z")

</div>

Hello! I’m currently working on a final for one of my classes, and I realized I needed to port all my code into another program so I can eventually host it on a website. But when I copy/paste my code from p5js to Dreamw…

---

## [P5.js V2.0.5 on own server: loadTable issues](https://discourse.processing.org/t/p5-js-v2-0-5-on-own-server-loadtable-issues/47441)

<div class="topic-metadata">

**Author:** [@RPI](https://discourse.processing.org/u/RPI)\
**Replies:** 2\
**Last updated:** [October 26, 2025, 12:39am UTC](https://discourse.processing.org/t/p5-js-v2-0-5-on-own-server-loadtable-issues/47441 "2025-10-26T00:39:38Z")

</div>

i have my project online editor when i ZIP download the code from there and copy it into my local RPI4 NGINX server browser can not find the needed file ( like table ) but that is understandable: http://192.168.1.10…

---

## [Question about //noprotect feature](https://discourse.processing.org/t/question-about-noprotect-feature/47401)

<div class="topic-metadata">

**Author:** [@horizontal\_shading](https://discourse.processing.org/u/horizontal_shading)\
**Replies:** 3\
**Last updated:** [October 19, 2025, 8:57pm UTC](https://discourse.processing.org/t/question-about-noprotect-feature/47401 "2025-10-19T20:57:18Z")

</div>

So as you all may know, there is a limit regarding how for loops work in p5.js. For example, this code draws many circles on top of each other on the canvas, but the process quickly halts & the canvas vanishes due to th…

---

## [P5 js V 2.0.5 orbitControl Android touch](https://discourse.processing.org/t/p5-js-v-2-0-5-orbitcontrol-android-touch/47396)

<div class="topic-metadata">

**Author:** [@RPI](https://discourse.processing.org/u/RPI)\
**Replies:** 0\
**Last updated:** [October 19, 2025, 2:41am UTC](https://discourse.processing.org/t/p5-js-v-2-0-5-orbitcontrol-android-touch/47396 "2025-10-19T02:41:30Z")

</div>

using orbit Control PC mouse: left: rotate middle (wheel ): zoom right: pan Android touch: one finger move: rotate 2 finger span: zoom 2 finger move: pan all works nice. but on Android browser, when i scroll do…

---

## [Error on atan() call](https://discourse.processing.org/t/error-on-atan-call/47373)

<div class="topic-metadata">

**Author:** [@Xero](https://discourse.processing.org/u/Xero)\
**Replies:** 2\
**Last updated:** [October 16, 2025, 8:33am UTC](https://discourse.processing.org/t/error-on-atan-call/47373 "2025-10-16T08:33:57Z")

</div>

Having an issue, is this a bug? or am I doing something wrong? function setup() { createCanvas(400, 400); background(128); } function draw() { let a = cos(0.5); text(a.toString(), 200,200); a = atan(0.5); t…

---

## [P5 js V 2.0.5 bezierVertex error](https://discourse.processing.org/t/p5-js-v-2-0-5-beziervertex-error/47182)

<div class="topic-metadata">

**Author:** [@RPI](https://discourse.processing.org/u/RPI)\
**Replies:** 10\
**Last updated:** [September 23, 2025, 2:02am UTC](https://discourse.processing.org/t/p5-js-v-2-0-5-beziervertex-error/47182 "2025-09-23T02:02:36Z")

</div>

code in online editor

---

## [Questioning the function of "let" when declaring a variable](https://discourse.processing.org/t/questioning-the-function-of-let-when-declaring-a-variable/47083)

<div class="topic-metadata">

**Author:** [@mugudeli601](https://discourse.processing.org/u/mugudeli601)\
**Replies:** 4\
**Last updated:** [September 5, 2025, 1:25pm UTC](https://discourse.processing.org/t/questioning-the-function-of-let-when-declaring-a-variable/47083 "2025-09-05T13:25:58Z")

</div>

Hello! I was following through this tutorial Variables and Change and learned about “let” when declaring a variable. However, I didn’t have to declare the variable outside the draw() with “let” in order to define a varia…

---

## [Let or nothing?](https://discourse.processing.org/t/let-or-nothing/46937)

<div class="topic-metadata">

**Author:** [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Replies:** 4\
**Last updated:** [August 16, 2025, 10:20am UTC](https://discourse.processing.org/t/let-or-nothing/46937 "2025-08-16T10:20:32Z")

</div>

Hello, If I create a new variable, I ‘m going to write let thing = 5; for example. But if I write thing = 5; (while I haven’t already created a variable ‘thing’) that works too! is there a difference? …

---

## [List of system variables](https://discourse.processing.org/t/list-of-system-variables/46924)

<div class="topic-metadata">

**Author:** [@jdiodato](https://discourse.processing.org/u/jdiodato)\
**Replies:** 1\
**Last updated:** [August 14, 2025, 6:20am UTC](https://discourse.processing.org/t/list-of-system-variables/46924 "2025-08-14T06:20:39Z")

</div>

Does anyone know if there’s a list of system variables somewhere in the p5 docs? I found this page in the docs that goes over mouseX and mouseY, but the AI overview from a quick Google search also pulls up a ton of other…

---

## [Table is not defined (p5.Table)](https://discourse.processing.org/t/table-is-not-defined-p5-table/46735)

<div class="topic-metadata">

**Author:** [@pemb](https://discourse.processing.org/u/pemb)\
**Replies:** 7\
**Last updated:** [July 16, 2025, 3:51pm UTC](https://discourse.processing.org/t/table-is-not-defined-p5-table/46735 "2025-07-16T15:51:15Z")

</div>

Hi all, I am having some trouble to make a new row in a csv file. While in the setup() function it seems I can access to the cvs data, it seems that in the draw() function and the callback function of a button I get “tab…

---

## [Switching Versions on p5.js Editor](https://discourse.processing.org/t/switching-versions-on-p5-js-editor/46656)

<div class="topic-metadata">

**Author:** [@Tipo](https://discourse.processing.org/u/Tipo)\
**Replies:** 0\
**Last updated:** [July 3, 2025, 1:42pm UTC](https://discourse.processing.org/t/switching-versions-on-p5-js-editor/46656 "2025-07-03T13:42:43Z")

</div>

How to switch to the latest release of p5.js 2.0!

---

## [Problem using p5 'esm' via jsdeliver (cdn)](https://discourse.processing.org/t/problem-using-p5-esm-via-jsdeliver-cdn/46279)

<div class="topic-metadata">

**Author:** [@dalanicolai](https://discourse.processing.org/u/dalanicolai)\
**Replies:** 3\
**Last updated:** [April 26, 2025, 8:34am UTC](https://discourse.processing.org/t/problem-using-p5-esm-via-jsdeliver-cdn/46279 "2025-04-26T08:34:20Z")

</div>

Hello, I am very new to javascript and even more to ES modules. However, I think I am trying things out correctly here. But as I am not sure if I am doing things right, I first drop a question here before I report an is…

---

## [Share function in menu](https://discourse.processing.org/t/share-function-in-menu/46249)

<div class="topic-metadata">

**Author:** [@Frankyates](https://discourse.processing.org/u/Frankyates)\
**Replies:** 3\
**Last updated:** [April 20, 2025, 1:02pm UTC](https://discourse.processing.org/t/share-function-in-menu/46249 "2025-04-20T13:02:23Z")

</div>

Hi The menu SHARE has disappeared From menu (it is a saved script) Can you help? Is this happening only in France?

---

## [Text Not Centered in Canvas - Help Needed with p5.js](https://discourse.processing.org/t/text-not-centered-in-canvas-help-needed-with-p5-js/46207)

<div class="topic-metadata">

**Author:** [@moracapaoladesign](https://discourse.processing.org/u/moracapaoladesign)\
**Replies:** 1\
**Last updated:** [April 13, 2025, 9:14am UTC](https://discourse.processing.org/t/text-not-centered-in-canvas-help-needed-with-p5-js/46207 "2025-04-13T09:14:37Z")

</div>

Hello everyone, I’m currently working on a p5.js project, and I’m having an issue with centering text on the canvas. Despite setting the text alignment to CENTER both horizontally and vertically, the text keeps appearin…

---

## [TypeError: Cannot read properties of undefined (reading '-5')](https://discourse.processing.org/t/typeerror-cannot-read-properties-of-undefined-reading-5/44916)

<div class="topic-metadata">

**Author:** [@JakobVirgil](https://discourse.processing.org/u/JakobVirgil)\
**Replies:** 13\
**Last updated:** [August 10, 2024, 3:57pm UTC](https://discourse.processing.org/t/typeerror-cannot-read-properties-of-undefined-reading-5/44916 "2024-08-10T15:57:32Z")

</div>

It gives line numbers like “at undefined:53042:53” The number ranges from 0 to -5 depending on the length of my code. here is the code

---

## [Current JavaScript Function Definition Syntax](https://discourse.processing.org/t/current-javascript-function-definition-syntax/45512)

<div class="topic-metadata">

**Author:** [@Quercus](https://discourse.processing.org/u/Quercus)\
**Replies:** 2\
**Last updated:** [December 27, 2024, 7:56pm UTC](https://discourse.processing.org/t/current-javascript-function-definition-syntax/45512 "2024-12-27T19:56:42Z")

</div>

I love the book Getting Started with p5.js that is published by Maker Media. The examples included are very helpful, but since the book is from 2016, those examples do not utilize function expressions or arrow syntax for…

---

## [Question about looping](https://discourse.processing.org/t/question-about-looping/45436)

<div class="topic-metadata">

**Author:** [@edufissure](https://discourse.processing.org/u/edufissure)\
**Replies:** 2\
**Last updated:** [December 7, 2024, 12:26am UTC](https://discourse.processing.org/t/question-about-looping/45436 "2024-12-07T00:26:38Z")

</div>

Hi im having a doubt… i know that draw is a endless loop, from beginning to las line of code…thats correct… The doubt cames if i create a function inside draw…lets say MovePacman(); MovePacman have a loop for moving f…

---

## [Why does the increment/decrement operator cause bugs when used in a recursive function?](https://discourse.processing.org/t/why-does-the-increment-decrement-operator-cause-bugs-when-used-in-a-recursive-function/45484)

<div class="topic-metadata">

**Author:** [@WaningJupiter](https://discourse.processing.org/u/WaningJupiter)\
**Replies:** 9\
**Last updated:** [December 19, 2024, 12:26pm UTC](https://discourse.processing.org/t/why-does-the-increment-decrement-operator-cause-bugs-when-used-in-a-recursive-function/45484 "2024-12-19T12:26:33Z")

</div>

Hello, I have a question about the behavior of the increment/decrement operator in recursive functions. Here’s a tree fractal pattern: function setup() { ... angleMode(DEGREES); } function draw() { ... drawBr…

---

## [P5.js Web Editor problem exporting a function](https://discourse.processing.org/t/p5-js-web-editor-problem-exporting-a-function/45420)

<div class="topic-metadata">

**Author:** [@edufissure](https://discourse.processing.org/u/edufissure)\
**Replies:** 4\
**Last updated:** [December 3, 2024, 2:07pm UTC](https://discourse.processing.org/t/p5-js-web-editor-problem-exporting-a-function/45420 "2024-12-03T14:07:33Z")

</div>

Hi im doing this test to import a class from a separate file: but i got error: The export: The import: The html file: Any help would be apreciated This is for educational purpose

[Next page](https://discourse.processing.org/c/p5js/p5js-beginners/16.md?page=1)
