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

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:)

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

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

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.