-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Labels
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.0
Web browser and version
firefox, chrome
Operating system
linux
Steps to reproduce this
Steps:
- Go to this link : https://editor.p5js.org/aman12345/sketches/g2-BEKriq
- Press any key
- See the error, you will see just an empty string " " on the console.
Snippet:
// Click on the canvas to begin detecting key presses.
let value = 0;
function setup() {
createCanvas(100, 100);
describe(
'A gray square with a black square at its center. The inner square becomes white when the user releases the "w" key.'
);
}
function draw() {
background(200);
// Style the square.
fill(value);
// Draw the square.
square(25, 25, 50);
// console.log(key)
}
// Set value to 255 the user releases the 'w' key.
function keyReleased() {
if (key === 'w') {
value = 255;
} else{
console.log(key);
}
// Uncomment to prevent any default behavior.
// return false;
}The expected behavior should be, when we press any key, the key must be shown on our console. The problem likely points to keyReleased().