Not computing an If statement? WHAT THE HECK?

Hi. I have a TFT and a PS2 keyboard plugged into my Arduino. I have an If statement. Here is what I want:

If the keyboard IS plugged in, it does this whole long text thing and rotates the display horizontally. Then it moves on.
If the keyboard is UNPLUGGED, it turns the display vertically, does not do a whole long text thing, and just moves on.

However, regardless of weather the keyboard is plugged in or not, it ALWAYS registers as unplugged! (And yes, the keyboard IS working) Here is some of my code:

void booting() {
    tft.fillScreen(BLACK);

  tft.setCursor(20,20);
  tft.setTextColor(WHITE); 
  tft.setTextSize(1);
  tft.setCursor(10,10);

if (keyboard.available()) {
  
  tft.print("Hardware ready! (EyeBook-Earth)");
  delay(1000);
  tft.println();
  tft.print("Basic bootform loading...");
    delay(1000);
    tft.println();
    tft.print("Starting sequence...");
 delay(1000);
 tft.print("Clear!");
 delay(10);
 tft.fillScreen(BLACK);
   tft.setCursor(10,10);
 tft.print("Booting: Eyesight-Classic 1.0");
 tft.println();
 tft.print("Created By Wesley R Tech");
 tft.println();
 tft.print("To boot to a different operating system, press S.Press T to trip the boot system.");
  tft.println();
 tft.print("Booting_ ");
    if (keyboard.read() == 's') {
//Boot Selector
    } else if (keyboard.read() == 't') {
 tft.fillScreen(BLACK);
    tft.setCursor(10,10);
  tft.print("Error: system_died");
}
  else {
  delay(3000);
  
  startup();
 }

}

else {
tft.print("Entering Mobile OS Mode");
tft.setRotation(1);
startup();
}

}

What am I doing wrong?

Please post the full code, and links to the versions of any libraries you installed for it. Thanks to the magic of open source and the ease of forking on github, there are often dozens of versions of any given library in circulation.

Does keyboard.available() do what you think it does? Check the docs for the library - usually .available() will return true if there's data to be read, not just if the keyboard is plugged in.

OMG! Stupid question! Tnx! Keyboard.avalible checks for an incoming keystoke!

Does anyone know how to test for a keyboard?

Does anyone know how to test for a keyboard?

The USB host shield initialization code should handle that.

The USB host shield initialization code should handle that.

he did say it was a PS/2 keyboard...

Does anyone know how to test for a keyboard?

According to here: http://www.computer-engineering.org/ps2keyboard/, PS/2 keyboards accept commands as well as sending keystrokes. You should be able to send a "reset" command and get a known response.
I don't recall seeing any functions in the existing PS/2 keyboard drivers for sending commands, though :frowning: You might have to write that yourself. (Hmm. Could be wrong. It looks like my own polled PS2 keyboard driver has a function to send a byte TO the keyboard. It has enough comments that perhaps it actually works, although it's been ages since I looked at that code... ps2keypolled/ps2keypolled.c at master · WestfW/ps2keypolled · GitHub)