Well, i would:
- use some variables "x velocity", "z velocity" for moving the character (floats)
- clamp velocity variables to your "max speed" (like.. between -10 and 10)
- when key is down you add/subtract to each variable by "acceleration" (float variable) - higher value, faster the character will get up to max speed
- multiply velocity variables by "de-celeration", which would be a value between 0 and 0.99 every frame, lower the amount - faster the character will slow down
You can alternatively play with gravity/sensitivity in your input settings, which is far simpler but not as flexible.