Why can't i view keycode value in the console window?


#1

Hey guy’s I’m trying to make a snake game in JS. Right now I’m making the function that will determine the direction of the snake, but at the moment I just want to log the keycode of any given key to the console, but it comes up as undefined? Why is this? I have the keycode stored into a variable before I log it? thanks for the help:)

http://jsfiddle.net/k12Lyr6c/


#2

Hi @sethrpabst, try keyCode instead, please note the camel case.
Cheers


#3

I would also add that keyCode is deprecated, and that the key is the better one to use instead.