processing/p5.js

key may be incorrect inside an event handler

Open

#7.569 aberto em 20 de fev. de 2025

Ver no GitHub
 (9 comments) (0 reactions) (0 assignees)JavaScript (3.178 forks)batch import
Area:EventsBugHelp Wanted

Métricas do repositório

Stars
 (20.784 stars)
Métricas de merge de PR
 (Mesclagem média 8d 13h) (45 fundiu PRs em 30d)

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

1.11.3

Web browser and version

Firefox 135.0 / Chromium 133

Operating system

Linux 6.13.2

Steps to reproduce this

Steps:

  1. Press key d
  2. Press and then release key a
  3. Release key d. In keyReleased key will be equal to a, though ev.key will be correct (d).

This happens since 1.11.3. In 1.11.2 and before everything works correctly.

There's also an issue with keyPressed in Firefox (not in Chromium). It fires continuously while a key is pressed, not just once. It is probably linked to this issue, since it started happening in 1.11.3, I don't know if I should create a new issue about that too.

Snippet:

function keyPressed(ev) {
	console.log(`pressed ${ev.key} (p5.key = ${key})`);
}

function keyReleased(ev) {
	console.log(`released ${ev.key} (p5.key = ${key})`);
}

Guia do colaborador