Deceleration after button press

Hello all! I am very new to JME and fairly new to Java as well. I am trying to make the movement of the cube more fluid by making it keep moving in the a direction after a movement key is pressed, but quickly decelerating to 0. I only have code in for this to happen when going right at the moment. It runs, but it seems that there is no effect. Are my numbers too small or is it something else? Here is the method I am currently speaking of:

 private ActionListener actionListener = new ActionListener() {
    public void onAction(String name, boolean keyPressed, float tpf) {
      if (name.equals("Pause") && !keyPressed) {
        isRunning = !isRunning;
      }
      if (name.equals("Right") && !keyPressed) {
        float j;
        for(j = (float)8.0; j >= 0; j = j - (float)0.005){
            Vector3f v = player.getLocalTranslation();
            player.setLocalTranslation(v.x + (float)1000*j*speed, v.y, v.z);
          }
      }
    }
  };

And here is all of my code in the class:

public class Main extends SimpleApplication {

    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }
 protected Geometry player;
  Boolean isRunning=true;
 
  @Override
  public void simpleInitApp() {
    Box b = new Box(1, 1, 1);
    player = new Geometry("Player", b);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    player.setMaterial(mat);
    rootNode.attachChild(player);
    initKeys(); // load my custom keybinding
  }
 
  /** Custom Keybinding: Map named actions to inputs. */
  private void initKeys() {
    // You can map one or several inputs to one named action
    inputManager.addMapping("Pause",  new KeyTrigger(KeyInput.KEY_P));
    inputManager.addMapping("Left",   new KeyTrigger(KeyInput.KEY_A));
    inputManager.addMapping("Right",  new KeyTrigger(KeyInput.KEY_D));
    inputManager.addMapping("Up",     new KeyTrigger(KeyInput.KEY_W));
    inputManager.addMapping("Down",   new KeyTrigger(KeyInput.KEY_S));
    inputManager.addMapping("Rotate", new KeyTrigger(KeyInput.KEY_SPACE),
                                      new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    // Add the names to the action listener.
    inputManager.addListener(actionListener,"Pause");
    inputManager.addListener(analogListener,"Left", "Right", "Up", "Down", "Rotate");
 
  }
 
  private ActionListener actionListener = new ActionListener() {
    public void onAction(String name, boolean keyPressed, float tpf) {
      if (name.equals("Pause") && !keyPressed) {
        isRunning = !isRunning;
      }
      if (name.equals("Right") && !keyPressed) {
        float j;
        for(j = (float)8.0; j >= 0; j = j - (float)0.005){
            Vector3f v = player.getLocalTranslation();
            player.setLocalTranslation(v.x + (float)1000*j*speed, v.y, v.z);
          }
      }
    }
  };
  
 
  private AnalogListener analogListener = new AnalogListener() {
    public void onAnalog(String name, float value, float tpf) {
      if (isRunning) {
        if (name.equals("Rotate")) {
          player.rotate(0, value*speed, 0);
        }
        if (name.equals("Right")) {
          Vector3f v = player.getLocalTranslation();
          player.setLocalTranslation(v.x + value*8*speed, v.y, v.z);
          
        }
        if (name.equals("Left")) {
          Vector3f v = player.getLocalTranslation();
          player.setLocalTranslation(v.x - value*8*speed, v.y, v.z);
        }
        if (name.equals("Up")) {
          Vector3f v = player.getLocalTranslation();
          player.setLocalTranslation(v.x, v.y  + value*8*speed, v.z);
        }
        if (name.equals("Down")) {
          Vector3f v = player.getLocalTranslation();
          player.setLocalTranslation(v.x, v.y - value*8*speed, v.z);
        }
      } else {
        System.out.println("Press P to unpause.");
      }
    }
  };
}

First, take a look at: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies

Then, in vectors… think:

pos = pos + velocity * tpf;
velocity = velocity + acceleration * tpf;

When you press the key, you can either set acceleration or if you want instant acceleration then just set the velocity. When the key is released, set the acceleration to the reverse direction * whatever ‘speed’ you want the deceleration to happen.

as pspeed says

think about objects as real life objects with newtons laws, so write code to change objects velocity only, but move object by “position = position + velocity * tpf” every frame infinitely, so when object stops, it still moves with 0 velocity