-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Task
Copy link
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.x
Web browser and version
Firefox
Operating system
Linux
Steps to reproduce this
In p5.js, we currently support some ways to detect which key a user presses: keyCode, key, and code are some of it. While keyCode and key are documented in the reference, the code variable has not yet been documented, which can lead to confusion for users.
Lines 463 to 465 in c39ad5c
| this.keyCode = e.which; | |
| this.key = e.key; | |
| this.code = e.code; |
-
keyreturns the character or value associated with the key press, regardless of the keyboard layout. -
codereturns the Constants on the keyboard (e.g., ENTER, ArrowUP), independent of what character is printed on that key.
Because only key is documented, users do not know that code exists or how it behaves.
Metadata
Metadata
Assignees
Type
Projects
Status
Done
Status
Completed