p5.js
p5.js copied to clipboard
keyTyped does not work in conjunction with returning false in mousePressed
Most appropriate sub-area of p5.js?
- [ ] Color
- [ ] Core/Environment/Rendering
- [ ] Data
- [ ] Events
- [ ] Image
- [x] IO
- [ ] Math
- [ ] Typography
- [ ] Utilities
- [ ] WebGL
- [ ] Other (specify if possible)
Details about the bug:
- p5.js version:
- Web browser and version: Chrome, version "80.0.3987.132"
- Operating System: Windows 10 OS Version 1909
- Steps to reproduce this: return false in mousePressed, and suddenly you can't access anything to do with the keyboard
print(key) does not print anything. Code is below
function setup() { createCanvas(400, 400); }
function draw() { background(220); }
function mousePressed() { return false; }
function keyPressed() { print(key); }
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.
I would like to work on this. Seems like an issue with an EventListener.
@BenMaydan I'm not able to replicate this locally, can this be a web editor bug?
with return false it triggers e.preventDefault(). my guess is that after the click, the iframe in web editor does not capture the cursor even if you click, and thus doesn't catch key events. If you click on the editor console and hit tab a few times to select iframe, key events are fired properly
sounds right, @micuat see the same https://editor.p5js.org/kll/sketches/tLtOxsq78 here.
I'd like to point out as of April 2022 I fould the same problem as OP, when I call return false on mousePressed() it breaks the code in keyPressed()
This issue only happens in the web editor, please file this bug over here instead. Thanks.