Skip to content

Commit a46490d

Browse files
authored
Merge pull request #7812 from dpanshug/doc-keyboard-bug
docs(keyboard): clarify keyIsDown() documentation for key codes and browser compatibility
2 parents 2a86107 + 3bbc47d commit a46490d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/events/keyboard.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,10 +832,16 @@ function keyboard(p5, fn){
832832
* }
833833
* ```
834834
*
835-
* `keyIsDown()` can check for key presses using
836-
* <a href="#/p5/keyCode">keyCode</a> values, as in `keyIsDown(37)` or
837-
* `keyIsDown(LEFT_ARROW)`. Key codes can be found on websites such as
838-
* <a href="https://keycode.info" target="_blank">keycode.info</a>.
835+
* `keyIsDown()` can check for key presses using strings based on
836+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key" target="_blank">KeyboardEvent.key</a>
837+
* or <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code" target="_blank">KeyboardEvent.code</a> values,
838+
* such as `keyIsDown('x')` or `keyIsDown('ArrowLeft')`.
839+
*
840+
* Note: In p5.js 2.0 and newer, numeric keycodes (such as 88 for 'X') are no longer supported.
841+
* This is a breaking change from previous versions.
842+
*
843+
* You can still use the p5 constants like `LEFT_ARROW` which now map to string values
844+
* internally rather than numeric codes.
839845
*
840846
* @method keyIsDown
841847
* @param {Number|String} code key to check.

0 commit comments

Comments
 (0)