I need help with keydown and keyup events

OK so I have a new problem. The longer I leave my game open the more the distance increases when I press the left/right keys. So when I open up my game the main characters movements are fine, one minute later and he starts teleporting again.