Add pointer and keyboard controls
See this course’s project requirements
An original interactive geometric artwork with palette and spacing controls, optional motion, a text description, inspected PNG and runnable source.
Keep your working files in your own notebook or software. Save a private description, checklist, and work link in My Proof.
What to include
- Coordinate, grid-count and edge-fit calculations.
- Two intentional original composition choices.
- Equivalent pointer/button/keyboard controls with boundary tests.
- Optional motion, pause and useful text support.
- Inspected PNG plus complete source and dependency notes.
Review and revise
Use these criteria to check your work and choose what to improve.
- The layout matches its calculations and fits the canvas.
- Controls update bounded state consistently.
- Motion and text support are usable and explained.
- Image and source handoff are complete.
Want more background?
The idea in everyday life
Create Tile Garden, an original geometric artwork with optional motion and multiple control routes.
An input handler changes state; the next draw uses that state to render the result.
Add pointer and keyboard controls — guided practice
Trace input events to bounded state changes with equivalent visible controls.
Save index.html and sketch.js from the practice files in the same new folder. Open index.html in a modern browser while online; the page loads the free p5.js 2.3.3 library from the CDN URL listed by the official download page. No account is needed. If you need offline use, download that library as p5.min.js from the official page and change only the library script src to p5.min.js. Edit sketch.js with a plain-text code editor, save, and reload the page after code changes. Use browser developer tools Console to inspect errors. Restore the original constants after each changed case unless instructed otherwise.
1. Test pointer and button
Click the canvas once, note the palette change, then click Next palette.
You should see: Both advance the same palette state through nextPalette.
Equivalent inputs can share one function instead of duplicating logic.
2. Test keyboard spacing
Tab to the canvas so its focus outline is visible. Press Right once from spacing 70, then Left once.
You should see: The status shows 75, then 70 pixels.
The key handler is scoped to the focused canvas and prevents arrow scrolling for those handled keys.
3. Test equivalent buttons
Use More spacing until the value stops, then Less spacing until it stops.
You should see: The allowed range is 40–80 pixels.
Visible buttons provide the same adjustment without requiring a canvas-specific keyboard gesture.
4. Inspect the guard
Read Math.max(40,Math.min(80,spacing+amount)). From 75, predict three +5 requests.
You should see: The results are 80,80,80.
Clamping constrains state before drawing uses it.
What to finish
A pointer/button/keyboard test log including both spacing boundaries.
Watch for this
Implementing a pointer-only control with no equivalent keyboard-operable option.
How can I tell I understand it?
Complete the changed case, explain your result, and pass the three application checks.
Quick knowledge check
Answer all 3 questions. Get at least 2 right and the lesson completes automatically.
You’ll get an explanation for each answer. Signed in? Your results save to your account.
Pass the check. We’ll save the progress.
Answer all 3 questions above and get at least 2 right. You can review the explanations and try again.
Go to the knowledge checkOptional course overview video · same video as Lesson 1
Creative Coding for Beginners with p5.js (1.1)
From The Coding Train. Watch here or open it on YouTube .
Optional course overview. Follow the written steps below at your own pace.Tools, templates, and lesson sources
Tools and templates
Tools open in a new tab so you can keep your place here.
Sources and further reading
Explore the references behind this lesson.
Source & access notes · checked 2026-09-12
Opened and inspected on 2026-09-12: Setup/draw, canvas and beginner editor workflow.
Access: Free public web page; no paid enrollment required.
Reuse: Public reference; link only. LifeStarter prose, exercises and files are independently authored.
Source & access notes · checked 2026-09-12
Opened and inspected on 2026-09-12: Using variables to change visual output.
Access: Free public web page; no paid enrollment required.
Reuse: Public reference; link only. LifeStarter prose, exercises and files are independently authored.
Report a problem with this lesson
Tell us what went wrong. Please leave out personal information and private project contents.