Why don't you modify your code so after key accerate is released, it slowly decreases the throttle.