We are about to switch to a new forum software. Until then we have removed the registration on this forum.
If KeyEvent.VK_ENTER or for that any garbage like KeyEvent.abcd is used anywhere in the program, it wont give error but none of the key presses are detected. The code does not give error but background doesn't change when enter or a is pressed.
Code:
import java.awt.event.KeyEvent;
void setup() {
size(500, 500);
background(0);
}
void draw() {
}
void keyPressed() {
if (key==KeyEvent.VK_ENTER)
background(255);
if (key=='a')
background(#EA1F1F);
if (key==Kefnvjkfjk)
background(255);
}
Answers
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
Where have you defined this mysterious Kefnvjkfjk variable??? [-(
Apart from that & the mal-formed post, your code works! >-)
GoToLoop, Sorry bot that! That the point. even though it is not defined it doesn't give any error on saving. "your code works! " the code works in the sense it executes as expected or you are having the same problem as i mentioned?
Sorry I didn't realize it was about "JS Mode"! It works in "Java Mode" of course! 8-X
However, you should know better that we can't
import
Java libraries into JavaScript! [-XSo i can't use minim and such extra's? How do i include the keyevent definitions then? X_X
In order for the "Java Mode" sketch to successfully transpile into "JS Mode", we need to follow PJS' API:
http://processingjs.org/reference/
And I question why you'd need KeyEvent in Processing even in "Java Mode".
Processing already got many PConstants w/ most used key codes like ENTER, LEFT, etc.!
Oh i didnt know they covered enter..! The PConstants will work fine! I am used to using the keyevent for backspace and stuff. Thanks for that! That will do for now but i can't import library in anyway? (probably out of scope for this discussion) but can i copy the code in those libraries from github and paste in in my JS? will it work(especially in case of minim(sound) lib)