Help needed with script

I need to be able to move the box forward/backward depending on the direction. My script doesn’t do that. How can I change it so it will work?
https://playcanvas.com/editor/code/356115/input.js