Keyboard output(Bit of a beginner)

#include <stdio.h>

int forward = 13; // Pin 12 - Forward
int reverse = 12; // Pin 11 - Reverse
int left = 7; // Pin 10 - Left
int right = 2; // Pin 9 - Right

char menu;

void setup() {

// initialize the digital pins as output
pinMode(forward, OUTPUT);
pinMode(reverse, OUTPUT);
pinMode(left, OUTPUT);
pinMode(right, OUTPUT); 
Serial.begin(9600); // Start serial communication at 9600bps
}    
    // Fordward action
void go_Forward() 
{
  digitalWrite(forward, HIGH);
  digitalWrite(reverse, LOW);
}

// Reverse action
void go_Reverse() 
{
  digitalWrite(reverse, HIGH);
  digitalWrite(forward, LOW);
}


// Left action
void go_Left() 
{
  digitalWrite(left, HIGH);
  digitalWrite(right, LOW);
}

// Right action
void go_Right() 
{
  digitalWrite(right, HIGH);
  digitalWrite(left, LOW);
}

// Stop turn action
void stop_Turn() 
{
  digitalWrite(right, LOW);
  digitalWrite(left, LOW);
}

// Stop car
void stop_Car() 
{
  digitalWrite(forward, LOW);
  digitalWrite(reverse, LOW);
  digitalWrite(right, LOW);
  digitalWrite(left, LOW);
}

void performCommand()
{
   
 do {   
        
         
        if (menu != 'e')
        {
           if(Serial.available())
           {
              menu = Serial.read();
           }
           switch(menu)
           {
               case 'w':
                 go_Forward();
                 break;
             
               case 's':
                 go_Reverse();
                 break;
                  
               case 'a':
                 go_Left();
                 break;
                 
                 case 'd':
                 go_Right();
                 break;
                 
                 case 'q':
                 stop_Car();
                 break;
                 
                 case 'r':
                 stop_Turn();
                 break;
             
               default:
                 printf("wrong character. Print menu again\n\n");
                 break;
           } // switch
        } // if
     } while(menu != 'e');
}

void loop()
{
  performCommand();
}

int main(){
  loop();
}

Here's what I have:

What you have were? That doesn't look like it does much useful on the Arduino.

The Arduino, at least mine, seem to be lacking in stdout and stdin capabilities.

Sorry, I put up the wrong code, changed it there. Is it possible to use keyboard keys as output for an arduino?

Sorry, I put up the wrong code, changed it there.

That's better, but...

You have a do/while loop that ends when the user sends 'e'. Then, loop() get called again, and processCommand() gets called again, so exiting really doesn't do anything.

Loose the do/while loop. It does nothing useful.

The IDE will add a main() to the code, if there is not one there. It does stuff a lot more/smarter than your main (like calling setup() and init()). Get rid of your main().

Is it possible to use keyboard keys as output for an arduino?

Sure. When you connect the keyboard the Arduino.

Otherwise, you need an application running on the PC to read the keypresses and send something to the Arduino. The Serial Monitor can, but it requires that you press Send/enter after each key. Kind of a pain. There are other apps that can send each key as pressed, or you could write your own that moved the car by moving the mouse, for instance. Processing might look useful.

Thanks for the advice. Here's how I've changed the code:

int forward = 13; 
int reverse = 12; 
int left = 8; 
int right = 7; 

char val;

void setup() {

// initialize the digital pins as output
pinMode(forward, OUTPUT);
pinMode(reverse, OUTPUT);
pinMode(left, OUTPUT);
pinMode(right, OUTPUT); 
Serial.begin(9600); // Start serial communication at 9600bps
}


// Fordward action
void go_forward() {
digitalWrite(forward, HIGH);
digitalWrite(reverse, LOW);
}

// Reverse action
void go_reverse() {
digitalWrite(reverse, HIGH);
digitalWrite(forward, LOW);
}


// Left action
void go_left() {
digitalWrite(left, HIGH);
digitalWrite(right, LOW);
}

// Right action
void go_right() {
digitalWrite(right, HIGH);
digitalWrite(left, LOW);
}

// Stop turn action
void stop_turn() {
digitalWrite(right, LOW);
digitalWrite(left, LOW);
}

// Stop car
void stop_car() {
digitalWrite(forward, LOW);
digitalWrite(reverse, LOW);
digitalWrite(right, LOW);
digitalWrite(left, LOW);
}

// Read serial port and perform command
void performCommand() 
{
	if (Serial.available()) 
	{ 
	  val = Serial.read();
	}
	if (val == 'w') 
	{
		go_forward(); 
	} 
	else if (val == 's') 
	{
		go_reverse(); 
	} 
	else if (val == 'd') 
	{
		go_right(); 
	}
	else if (val == 'a') 
	{
		go_left(); 
	} 
	else if (val == 't') 
	{
		stop_turn();
	}
	else if (val == 'q') 
	{
		stop_car(); 
	}
}


void loop() 
{
	performCommand();
}

I've looked up how to send keypresses to an arduino but all I keep finding are pages about using the arduino as a keyboard, kind of the opposite of what I want.

One problem with that code is that the processCommand() function will be called over and over. If there is no new serial data, the old serial data will be reused. That really isn't necessary, since the pin state changes that happen in response to a serial command are persistent.

The actions taken in response to serial input should happen inside the if(Serial.available() > 0) block.

I've looked up how to send keypresses to an arduino but all I keep finding are pages about using the arduino as a keyboard, kind of the opposite of what I want.

What application on the PC is going to be responsible for this? I mentioned Processing earlier as one possibility. It can read keyboard input, and send data to the Arduino as each key is pressed. It can also send data based, for instance, on mouse position, so moving the mouse could move the car.

The reason that I mention this is because your vehicle has no control over its speed. Pressing a key starts the car moving, forward, backwards, left, or right, but at a constant speed.

Using the mouse, you could have the car change speed as the mouse moved away from the center, like a joystick.

What application on the PC is going to be responsible for this?

I've just been using the serial monitor, I don't know what application I could use. I'll look into Processing, thanks.

If you are running Windoze then Hyperterminal can be used to send PC keystrokes directly to Arduino. Hyperterminal will also let you copy contents to the clipboard for paste elsewhere.