Skip to content

[p5.js 2.0 Bug Report]: KeyReleased() is not working in p5.js 2.0 #7759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 17 tasks
perminder-17 opened this issue Apr 19, 2025 · 1 comment
Closed
1 of 17 tasks

Comments

@perminder-17
Copy link
Contributor

perminder-17 commented Apr 19, 2025

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.0

Web browser and version

firefox, chrome

Operating system

linux

Steps to reproduce this

Steps:

  1. Go to this link : https://editor.p5js.org/aman12345/sketches/g2-BEKriq
  2. Press any key
  3. See the error, you will see just an empty string " " on the console.

Snippet:

// Click on the canvas to begin detecting key presses.

let value = 0;

function setup() {
  createCanvas(100, 100);

  describe(
    'A gray square with a black square at its center. The inner square becomes white when the user releases the "w" key.'
  );
}

function draw() {
  background(200);

  // Style the square.
  fill(value);

  // Draw the square.
  square(25, 25, 50);
  // console.log(key)
}

// Set value to 255 the user releases the 'w' key.
function keyReleased() {
  if (key === 'w') {
    value = 255;
  } else{
    console.log(key);
  }
  // Uncomment to prevent any default behavior.
  // return false;
}

The expected behavior should be, when we press any key, the key must be shown on our console. The problem likely points to keyReleased().

@perminder-17
Copy link
Contributor Author

This is fixed by #7758. Hence closing this issue.

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

No branches or pull requests

1 participant