I need help with keydown and keyup events

You can use the technique here to get the time in milliseconds between frames.

In your draw functions you want to multiply the movementSpeed by timeElapsed to get a consistent rate of movement for a smooth animation.