Serial Read delay

I am trying to read data off serial port 3 (pins 14,15) and there seems like a delay of some sort. It reads serial data once the buffer is filled I guess and so it has some secs of delay and sends to the program serial port. I need the program to do it instantly as soon as the data arrives. Please help.

loop:
while(Serial3.available())
{
char data = Serial3.read();
Serial.write(data);

}

the serial communication lag happens when usbhost is enabled and keyboard is plugged in. Else it works fine. Please help to solve the USB host issue

There is nothing special about Serial3 - it is EXACTLY the same as Serial1 and Serial2, and makes the data available as soon as it is received. If you are seeing a delay or some kind of line buffering, it is happening on the other end of the Serial connection. Many terminal programs (Serial Monitor included) send nothing until Return is entered...

Regards,
Ray L.

There is a fix for the USB keyboard 5 second delay in the USBHost git repo.