You need to separate your input handling from your updates/movement. The easiest way is to set a boolean flag when a key is pressed/released and then
in your game loop do your movement depending on what is pressed. See
my reply here to see an example of how to do this.
By the way, you should really not be using global variables (static keyword) and instead use an OOP model.