Arduino Uno and Keyboard

I am trying to say get inputs from the keyboard, into the serial port either using the switch case or if statements, without using the 'Enter' key. I am able to turn on and off lights by putting in the a number say '1' and pressing '2' to turn it off. but whenever i wanna use the keyboard library it says that I need an Arduino Leonardo.

here is my code pretty simple. trying to get the basics down so I can implement it on my robot.

int upPin = 8;
int downPin = 6;
int rightPin = 9;
int leftPin = 7;
/* Use a variable called byteRead to temporarily store
   the data coming from the computer */
byte byteRead;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  Serial.begin(9600);
  pinMode(upPin, OUTPUT);
  pinMode(downPin, OUTPUT);
  pinMode(rightPin, OUTPUT);
  pinMode(leftPin, OUTPUT);
 }
// the loop routine runs over and over again forever:
void loop() {
    if (Serial.available()> 0) {
    /* read the most recent byte */
      byteRead = Serial.read();
    /*ECHO the value that was read, back to the serial port. */
    Serial.write(byteRead);
    if(byteRead == '1'){
      digitalWrite(upPin, HIGH);   // turn the LED on (HIGH is the voltage level)
        // wait for a second
    }
    if(byteRead == '2'){
      digitalWrite(downPin, HIGH);    // turn the LED off by making the voltage LOW
    }
    if(byteRead == '3'){
      digitalWrite(rightPin, HIGH);    // turn the LED off by making the voltage LOW
    }
    if(byteRead == '4'){
      digitalWrite(leftPin, HIGH);    // turn the LED off by making the voltage LOW
    }
    if(byteRead == '5'){
      digitalWrite(leftPin, LOW);   
      digitalWrite(upPin, LOW);
      digitalWrite(downPin, LOW);
      digitalWrite(rightPin, LOW);
    }
  }
}

but whenever i wanna use the keyboard library it says that I need an Arduino Leonardo.

The keyboard library allows the Arduino to emulate a keyboard and send keyboard events to a program running on your PC. I think you are doing something different.

DavidOConnor:

but whenever i wanna use the keyboard library it says that I need an Arduino Leonardo.

The keyboard library allows the Arduino to emulate a keyboard and send keyboard events to a program running on your PC. I think you are doing something different.

by the keyboard library i meant the functions like Keyboard.press() and such. Is there anyway to use does on Arduino Uno?
because when i write my code using those i get an error saying that I need the Lenoardo and the keyboard is not in the scope.

You can't use the Keyboard library with Arduino Uno.

I am trying to say get inputs from the keyboard, into the serial port

Even if you could use the Keyboard library, it won't do this.

Your code looks like it accepts serial data from the PC, and sets the output pins HIGH or LOW.

Your description sounds like you want to get serial data from the keyboard on the PC, which seems to match with the code.

For this, you do not need the keyboard library, which is for the Leonardo, and which implements a keyboard that sends keystrokes TO the PC.

If I read your query correctly, the only problem you have is that you have to hit ENTER to send the keys. If this is correct, I can tell you that the Serial Monitor in the Arduino IDE will not allow you to do this. What will allow you to do this is a terminal program. I use TeraTerm, but there are many others. putty, hyperterminal, and many more. You can, of course, use a PC program you write yourself, in whatever language you are comfortable with.