Requesting script: Reduce velocity to 0 if parameter = 1

Hello everyone

I am very new to python and BGE, so far I have been able to do most of what I need via logic bricks or with the help of tutorials but this one is stumping me.

I am building a space flight game and need to find a way to allow players to easily stop their ship. What I think I need is a code that is triggered on keyrelease, if parameter inertialDampner == “1” get current velocity of player’s ship, then set velocity to 0 over the course of (velocity/10) seconds eg. if velocity == 100 it takes 10 seconds to slow down.

Also if you have a suggestion on another way I can achieve this please let me know