Skip to content

keyPressed event: upper and lower case #536

@shiffman

Description

@shiffman

I'm noticing that in keyPressed() I always get a capital letter for any key pressed. For example with both 'a' and 'A' I get the following:

key code: 65
key: 'A'
function keyPressed() {
  console.log("p5 keyCode: " + keyCode);
  console.log("p5 key: " + key);
}

With native browser events, however

window.addEventListener("keypress", function(e) {
  console.log("native keycode: " + e.which);
  console.log("native key: " + String.fromCharCode(e.which));
});

I get:

key code: 97
key: 'a'

and

key code: 65
key: 'A'

Is this on purpose for a reason I'm missing?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions