We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I made just simple application in Java mode with keyboard input and it works fine, when I write somethink I see letters on the screen. I didn't import any library, is just really simple. Now I tried to change Java mode to Javascript, but when I am trying this program in web browser it writes just ASCII nunbers. For exammple if I press 'k' I have 107 on the screen. How to solve this.
This is code after void key pressed for keyboard input:
text1+=key;
Another question, is it possible to put Java application from processing Java mode on webpages? Will it work? Is it hard to make it possible?
RFranta
Answers
JavaScript doesn't have a
char
data-type, which variable key is! (~~)It's either a floating-point number or a string. Not a middle ground as a character!
For those situations, Processing provides convert functions.
And in order to get a String, we specifically use the str() function:
http://processing.org/reference/strconvert_.html
Some time ago, it was pretty easy. But nowadays, it's better to stick w/ JS Mode if possible.
If you really need it, I advise you to use the import application (CTRL+E) from the old Processing v1.5.1.
There's a tool for Processing 2+, but I can't remember its name right now!
Thank you for great aswers!