Closed good-grief closed 8 years ago
keyPressed is a global event, even when you are in instance mode. it will fire anytime a key is pressed, so if you try to attach more than one keyPressed event, they may not both be fired.
Thanks. I found a way to deal with it.
@good-grief Can you explain your workaround ? I have a problem with that too. Even if I don't use keyPressed in one sketch but I instanciate multiple sketches the function does work.
You could create a normal event.
// es6
document.addEventListener('keydown', e => {
if (e.keyCode == '37') {
// Something
}
});
Thanks a lot @alexdean .
In a scenario with multiple sketches the
keyPressed
-event is only received by the first sketch. This behavior is not similar to other events (e.g.mouseClicked
).Here is some code to demonstrate the problem:
Thanks