Awazez
1
Hi !
I’m quite new in javascript and I tried to program a Flappy bird with the coding train video.
I did a function named KeyPressed
function KeyPressed () {
if (key == "") {
console.log("SPACE");
}
}
But it’s not working and I don’t see anything appear when I press space in the console. Can you help me with it ? Thanks !
1 Like
""
is an empty String. Use " "
(or ' '
) instead for the space character. 
P.S.: Edit & format your posted code. 
1 Like
Awazez
3
Yeah ! It’s working. Thanks a lot !
kll
4
also it should be
function setup() {
}
function draw() {
}
function keyPressed() {
print("keyPressed "+key+" keyCode "+keyCode);
if ( key == ' ' ) console.log("[space]");
}
and we see it ?
in browser / inspect / Console
1 Like
Awazez
5
Thanks a lot for the fast answer !