processing/p5.js

key may be incorrect inside an event handler

Open

#7,569 建立於 2025年2月20日

在 GitHub 查看
 (9 留言) (0 反應) (0 負責人)JavaScript (3,178 fork)batch import
Area:EventsBugHelp Wanted

倉庫指標

Star
 (20,784 star)
PR 合併指標
 (平均合併 8天 13小時) (30 天內合併 45 個 PR)

描述

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})`);
}

貢獻者指南