Increasing access
This feature would increase access by making it easier for learners and users transitioning from p5.js 1.x to 2.0 to identify and fix breaking changes.
Most appropriate sub-area of p5.js?
Feature enhancement details
in p5.js 2.0, there was an important change to how key and code are handled to align better with the widely used web standards spec reference.
Previously, it was common in 1.x to compare keyCode directly to constants like RIGHT_ARROW and LEFT_ARROW.
if (keyCode === RIGHT_ARROW) {
background(0);
} else if (keyCode === LEFT_ARROW) {
background(100);
}
Though this works in 1.x, it no longer works in 2.0 due to the standardization update. Now, users must use:
if (keyIsDown(RIGHT_ARROW)) {
background(0);
} else if (keyIsDown(LEFT_ARROW)) {
background(100);
}
Problem: Many 1.x users are accustomed to using keyCode === without needing to reference documentation. Since this behavior no longer works in 2.0, it can be confusing and lead to subtle bugs when transitioning projects. This can be particularly frustrating for those who rely on prior p5.js experience.
Currently there is no warning given when keyCode === is used, which can be harder to debug.
Proposed Solution: Add a Friendly Error System warning that:
- Detects patterns where
keyCode is compared using === or ==
- Shows a warning suggestion to use
keyIsDown() instead
- (Maybe) link to the updated documentation for
keyIsDown()
Possible warning message: keyCode === is deprecated in p5.js 2.0. Please use keyIsDown instead. See https://beta.p5js.org/reference/p5/keyisdown/ for more information.
Increasing access
This feature would increase access by making it easier for learners and users transitioning from p5.js 1.x to 2.0 to identify and fix breaking changes.
Most appropriate sub-area of p5.js?
Feature enhancement details
in p5.js 2.0, there was an important change to how
keyandcodeare handled to align better with the widely used web standards spec reference.Previously, it was common in 1.x to compare
keyCodedirectly to constants likeRIGHT_ARROWandLEFT_ARROW.if (keyCode === RIGHT_ARROW) {
background(0);
} else if (keyCode === LEFT_ARROW) {
background(100);
}
Though this works in 1.x, it no longer works in 2.0 due to the standardization update. Now, users must use:
if (keyIsDown(RIGHT_ARROW)) {
background(0);
} else if (keyIsDown(LEFT_ARROW)) {
background(100);
}
Problem: Many 1.x users are accustomed to using
keyCode ===without needing to reference documentation. Since this behavior no longer works in 2.0, it can be confusing and lead to subtle bugs when transitioning projects. This can be particularly frustrating for those who rely on prior p5.js experience.Currently there is no warning given when
keyCode ===is used, which can be harder to debug.Proposed Solution: Add a Friendly Error System warning that:
keyCodeis compared using===or==keyIsDown()insteadkeyIsDown()Possible warning message:
keyCode ===is deprecated in p5.js 2.0. Please usekeyIsDowninstead. See https://beta.p5js.org/reference/p5/keyisdown/ for more information.