Skip to content

[p5.js 2.0 Bug Report]: Add documentation for the code system variable in key handling. #7881

@perminder-17

Description

@perminder-17
Collaborator

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.

this.keyCode = e.which;
this.key = e.key;
this.code = e.code;

  • key returns the character or value associated with the key press, regardless of the keyboard layout.

  • code returns 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

Status

Ready for Work

Status

In Progress

Relationships

None yet

    Development

    Participants

    @ksen0@perminder-17

    Issue actions

      [p5.js 2.0 Bug Report]: Add documentation for the `code` system variable in key handling. · Issue #7881 · processing/p5.js