Linking remote arrows to DC Motor gear

Hello all,
I am just having trouble trying to figure out how make the two DC Motor Gears I have on my acrylic car move when different buttons are clicked.

This is the keypad of the buttons and their IDs:

1 2 3

4 5 6

7 8 9

2 = Forward = FF18E7
8 = Backwards = FF4AB5
4 = Left = FF10EF (Right motor goes forward, left goes back)
6 = Right = FF4AB5 (Left motor goes forward, right goes back)

I know to make the motors move you can write:
//digitalWrite(2,HIGH);
//digitalWrite(4,LOW);
//digitalWrite(5,HIGH);
//digitalWrite(6,LOW);
//digitalWrite(7,HIGH);

...although i'm not sure how to distinguish the buttons to make it when one is clicked (like left for example) the motors will know to do this (only wen a particular button is held down).

So far i have this to distinguish the pins from a friend:
#include <IRremote.h>
int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;
long lastValid = 0xFFFFFFFF;

void setup() {
pinMode(7, INPUT); // IR Rx
irrecv.enableIRIn(); // start the IR receiver
Serial.begin(9600); // setup console
}

void loop() {
if (irrecv.decode(&results)) {
if (results.value == 0xFFFFFFFF){
Serial.println(lastValid, HEX);
} else {
Serial.println(lastValid, HEX);
lastValid = results.value;
}
delay(500);
irrecv.resume(); // Receive the next value
}
}

If any other information is needed, please let me know and thank you for your time

I am just having trouble trying to figure out how make the two DC Motor Gears I have on my acrylic car when different buttons are clicked.

How to make them do what? Let smoke out?

   delay(500);

Replace this useless code with a switch statement, based on lastValid. There will be one case for each of the IR buttons you want to handle. In the cases, you control the motors.

There really is no point in dealing with the repeat code. Pressing a button should initiate some action, which should continue until another action is selected.

Hello,
Apologies for that, i missed a word and the question has been edited. I am trying to get the motors to rotate as buttons like left, right, forward and backwards are clicked. Also you are right, keeping them going in that direction until another button is clicked is a better idea but how would i be able to do this? I will change the delay to something lower to receive the IR signal quicker as well.

Thank you for your response

i missed a word and the question has been edited.

Please don't do that. Make a correction in a new reply. Don't change the original post, to make the person that commented on the mistake look silly, for pointing out a now non-existent error.

but how would i be able to do this?

When you write a digital pin HIGH or LOW, it stays in that state, without you needing to keep setting the state.
When you write a value to a PWM pin, it keeps outputting that duty cycle, without you needing to keep setting the duty cycle.

So, once you set the directions and speed appropriate for a button press, the car will keep going that way, at that speed, until you make it do something else.

Hello,
Thank you for explaining about the high and low pin states, that helped. I had to change the original post so everyone else who read it would understand what I am trying to ask or else they won't also be able to answer it - and I will have more people checking the comments for what I was supposed to say, or themselves saying that the motor will smoke out again. I'm not sure how I could have made it easier without referencing what it usually was, which I did ,"Apologies for that, i missed a word and the question has been edited".

Now that I know to set the speed and direction of a wheel, how would i write this and link it up to the IR remote buttons using the 2,8,4,6?