Skip to content
Advertisement

Keyboard Arrow Key Controls in Javascript

JavaScript

This code is not working.

The object I’m trying to move is not moving when I’m pressing the Up & Down Arrow Key.

Advertisement

Answer

You should do something like that:

JavaScript

The position attribute of the “ship” must be like “relative”. By the way, e.keyCode is deprecated, you can use e.code instead ^^

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement