Arduino + processing + DC motor

Hello there! I am working on a rover project that i finished a while ago, but i would like to add control capability through processing depending on keyboard input.
I have attempted to do so with little proccesing knowledge. However in my code when i press the correct key the motor turns on and works abut stays on even if i let go of the key. if anyone could help me i want to make it so the motor only turns when im actually pressing down the key!
here is my code:
Arduino:

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"


Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 

Adafruit_DCMotor *myMotor = AFMS.getMotor(1);

char c;

void setup()
{

  Serial.begin(9600);

  AFMS.begin();

}


void loop()
{

  char c;

  if (Serial.available()){
    c = Serial.read();

    if (c == 'w'){

      myMotor->setSpeed(150);
      myMotor->run(FORWARD);
    }

    if (c == 'p'){
      myMotor->setSpeed(150);
      myMotor->run(BACKWARD);
    }
    if(c == 'o'){
      myMotor->setSpeed(0);

    }


  }

}

Processing:

import processing.serial.*;

Serial myPort;

void setup()
{
  myPort = new Serial(this, "COM5", 9600);
  println(Serial.list());
}


void draw()
{

  if (keyPressed) {

    if (key == 'w') {

      myPort.write('w');
    } else if (key == 'p') {

      myPort.write('p');
    } else {

      myPort.write('o');
    }
  }
}

Thank you!!

However in my code when i press the correct key the motor turns on and works abut stays on even if i let go of the key

What does your Processing code do is there is no key pressed? Nothing. Why should the Arduino not keep doing what it was told to do, when Processing is not telling it to do something different?
You need an else clause in the Processing program to tell the Arduino to stop doing whatever it is doing.
You might also need to deal with the key being held down. Do you want to keep sending the value, or do you want to send a value once per key press, regardless of how long the key is held down?

Thats good avice thank you! And yes i want it to send continuos values while the key is pressed down

And yes i want it to send continuos values while the key is pressed down

You might think about sending one value when the key is pressed, and another when it is released. Fortunately, that is possible for most keys - send the upper case version when pressed, and the lower case version when released.
That's far better than spamming the Arduino with serial data that it takes time to process.

I just did did what you said and it worked perfectly thank you!