Usb host shield not working with keyboard

Im trying to get a usb host shield to work with an Arduino mega but what is happening is that it isnt sending data to the ide. (At least thats what i think is happening thought i could be wrong) everything that should be solder is, each component is getting the correct voltage. The ide doesn't show any errors just when i press a key on the keyboard nothing comes up on the serial monitor

Please share your code, along with wiring diagrams

what do you mean with "to the IDE" ?

What i meant to say was the serial monitor because when it should be working as you probably know it prints out the output on to the serial monitor and when i press a key it doesn't do that it could be that i don't have enough power running into it to power the keyboard but i don't know how to give it more power

Here's the code:

#include <hidboot.h>
#include <usbhub.h>

// Satisfy the IDE, which needs to see the include statment in the ino too.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif
#include <SPI.h>

class KbdRptParser : public KeyboardReportParser
{
    void PrintKey(uint8_t mod, uint8_t key);

  protected:
    void OnControlKeysChanged(uint8_t before, uint8_t after);

    void OnKeyDown	(uint8_t mod, uint8_t key);
    void OnKeyUp	(uint8_t mod, uint8_t key);
    void OnKeyPressed(uint8_t key);
};

void KbdRptParser::PrintKey(uint8_t m, uint8_t key)
{
  MODIFIERKEYS mod;
  *((uint8_t*)&mod) = m;
  Serial.print((mod.bmLeftCtrl   == 1) ? "C" : " ");
  Serial.print((mod.bmLeftShift  == 1) ? "S" : " ");
  Serial.print((mod.bmLeftAlt    == 1) ? "A" : " ");
  Serial.print((mod.bmLeftGUI    == 1) ? "G" : " ");

  Serial.print(" >");
  PrintHex<uint8_t>(key, 0x80);
  Serial.print("< ");

  Serial.print((mod.bmRightCtrl   == 1) ? "C" : " ");
  Serial.print((mod.bmRightShift  == 1) ? "S" : " ");
  Serial.print((mod.bmRightAlt    == 1) ? "A" : " ");
  Serial.println((mod.bmRightGUI    == 1) ? "G" : " ");
};

void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
{
  Serial.print("DN ");
  PrintKey(mod, key);
  uint8_t c = OemToAscii(mod, key);

  if (c)
    OnKeyPressed(c);
}

void KbdRptParser::OnControlKeysChanged(uint8_t before, uint8_t after) {

  MODIFIERKEYS beforeMod;
  *((uint8_t*)&beforeMod) = before;

  MODIFIERKEYS afterMod;
  *((uint8_t*)&afterMod) = after;

  if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) {
    Serial.println("LeftCtrl changed");
  }
  if (beforeMod.bmLeftShift != afterMod.bmLeftShift) {
    Serial.println("LeftShift changed");
  }
  if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) {
    Serial.println("LeftAlt changed");
  }
  if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) {
    Serial.println("LeftGUI changed");
  }

  if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) {
    Serial.println("RightCtrl changed");
  }
  if (beforeMod.bmRightShift != afterMod.bmRightShift) {
    Serial.println("RightShift changed");
  }
  if (beforeMod.bmRightAlt != afterMod.bmRightAlt) {
    Serial.println("RightAlt changed");
  }
  if (beforeMod.bmRightGUI != afterMod.bmRightGUI) {
    Serial.println("RightGUI changed");
  }

}

void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key)
{
  Serial.print("UP ");
  PrintKey(mod, key);
}

void KbdRptParser::OnKeyPressed(uint8_t key)
{
  Serial.print("ASCII: ");
  Serial.println((char)key);
};

USB     Usb;
USBHub     Hub(&Usb);
HIDBoot<USB_HID_PROTOCOL_KEYBOARD>    HidKeyboard(&Usb);

KbdRptParser Prs;

void setup()
{
  Serial.begin( 115200 );
#if !defined(__MIPSEL__)
  while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
  Serial.println("Start");

  if (Usb.Init() == -1)
    Serial.println("OSC did not start.");

  delay( 200 );

  HidKeyboard.SetReportParser(0, &Prs);
}

void loop()
{
  Usb.Task();
}

I doubt its a problem with the code since I use the code straight from the examples
And with the wiring diagram would it be fine if i send a picture of how everything was set up since i don't know how to properly do a wiring diagram

Does the serial monitor print anything at all? Like "Start" or "OSC did not start."
Do you have the serial monitor open at correct baud rate of 115200 bauds?

I do have the correct baud rate set ive checked that many time and the serial monitor does print Start its only when i press a on the keyboard that is connected to the usb host shield nothing comes up

i have the same problem with you, i wonder if you have it solved and how

It sounds like you're having trouble with the USB host shield and Arduino Mega setup. Here are a few things to check: First, make sure you have the correct USB Host Shield library installed and that your code is properly set up to read data from the keyboard. Double-check the connections to ensure the USB Host Shield is securely attached to the Arduino Mega and all pins are properly seated. Verify that your Arduino Mega is getting adequate power, as insufficient power can cause issues with peripherals. Also, ensure the Serial Monitor's baud rate matches the rate specified in your sketch, as a mismatch can prevent data from appearing. Confirm that the USB Host Shield is correctly initialized in your code, and check for any compatibility issues between the shield and your Arduino Mega. Adding debugging output to your code can also help identify where the problem might be occurring. If these steps don’t resolve the issue, sharing your code or additional details might help others assist you further.

Best of luck, and I hope you get it working soon!

Blockquote