P5.js - Mouse and keys stuck

Hi,

I’ve been experimenting with p5.js for a bit, and I’ve noticed that the mouse and key functions sometimes get stuck.

The problem is caused for me when you right-click, or hold a key, then right-click. (In the sketch below)

Here is an example of the problem I’m facing:
editor.p5js.org/SarahJ/sketches/ByNHnh56X

Thanks!

did you experiment with the

  // prevent default
  return false;

i see
https://p5js.org/reference/#/p5/mousePressed

2 Likes

Thanks for the tip - I’ve added it to the program. Unfortunately, the problem still occurs with the same reasons as before. I’m using macOS Sierra - Could that be the cause?

no idea about OS,
also possibly a browser problem,
but to separate the problem from the
p5.js site environment
try do a download and ftp upload to a server.

Thanks - I’ll try that.

p.s. your latest code after add that “tip” also
for the keyboard, i see now under win7 / firefox /
that the keyboard is not working at all, ( [space] gives a jump because it seems to force firefox to reload the page )
mouse press OK

//___________
the resulting thing what is send to the browser is as i understand a .png,
and all browser open on mouse right click the image save menu,
possibly you should do like
mousePressed
if mouseButton == LEFT … move true;

That’s what I was considering too, but I wanted to know first if it was a bug or something fixable.

on
win7 SP0 : ( 32bit )
firefox 63. || chrome 70.
using
https://editor.p5js.org/ || Processing 3.4 mode p5.js

use right mouse button:
press and hold and release

i see in console || inspect console

mouse pressed 
right-click 
mouse released 
right-click 

despite the upcoming context menu

Weird… Must be a Mac bug then. I’m going to try using a mouse and see what happens.

I’ve figured out how to fix it, it seems when you right-click in Chrome it opens up a context menu (which takes away focus from the browser), so if you disable that it should work. You can disable it by putting:
oncontextmenu=" event.preventDefault(); in sketch.js
or
<body oncontextmenu="return false;"> in index.html

1 Like

Is that a string assignment or some typo? :thinking:

Maybe this 1 should work too? :man_shrugging:
oncontextmenu = () => false;

1 Like