Make an object rotate on a key press, then un-rotate when key is releases.

Hello.

I have been working on my first game for awhile, but have run into a problem.

I want to make my character rotate 45 degrees left or right when I press the A or D key. Then when I release the key I want the character to un-rotate so it is facing straight ahead again.

any help in how to code this in java script is greatly appreciated.
Thanks.

Is there anyone who is able to help me with this problem?

just rotate it when input.getkeydown and rotate it back when input.getkeyup

if u need help to script it send me a p.m

Oh. I didnt think about using getkey up and down. I will give it a try now. Thanks for your help.

but is it going from 0 to 45 linear and smoothly or it just jumps from 0 to 45 instantly? (disappearing and reappearing 45 deg.)

You’re replying to a thread from 2014.

Sorry, it wasn’t locked so i accidentally replied.
I will look for a newer thread for that or i will create a new thread if i don’t find what i need (kinda hard).
Btw what forum fits more for what i want to ask?