Need Help with Arduino Uno as USB Keyboard

I'm trying to setup an Arduino Uno R3 as a simple USB keyboard and I'm having a hell of time getting anything to work.

All I'm trying to do is have the Arduino send a string when it power up, then enter an infinite loop to never send the string again. I have the firmware file that I can flash the 16U2 as a HID device. But every time I go to test the board out, it screws up all USB keyboard on the systems and I'm forced to reboot to get any keyboards to work again. Here is the simply program I'm trying to write.

void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}

void loop() {
Serial.write("hello");
digitalWrite(LED_BUILTIN, HIGH);
while( true ){
}
}

I'm using the onboard LED to indicate that the program is complete.

I apologize in advance for bothering anyone with such a stupid request.

I've seen those examples, and I did get the random char/delay one to work. But I need help sending full strings instead of single characters.

The ASCII characters must be translated to USB key codes before being sent to the 16U2. There is code to do this in Keyboard.cpp/Keyboard.h. The Keyboard library is designed for native USB devices such as Leonardo and Pro Micro but you could extract the ASCII to key code functionality and use it with the 16U2 HID keyboard. Perhaps someone has already done this.

Ok. I managed to get it working in a very quick and dirty way:

uint8_t buf[8] = { 
  0 };   /* Keyboard report buffer */

#define KEY_LEFT_SHIFT  0x02

void setup() 
{
  Serial.begin(9600);
  randomSeed(analogRead(0));
  delay(200);
}

void loop() 
{
  buf[2] = 4;
  Serial.write(buf, 8);
  releaseKey();
  buf[2] = 5;
  Serial.write(buf, 8);
  releaseKey();
  buf[2] = 6;
  Serial.write(buf, 8);
  releaseKey();
  buf[2] = 7;
  Serial.write(buf, 8);
  releaseKey();

  while( true ){
  }
}

void releaseKey() 
{
  buf[0] = 0;
  buf[2] = 0;
  Serial.write(buf, 8); // Release key  
}

That types out 'ABCD'.

I would still like to be able to write the characters in a more efficient way. But I guess that's just a matter of creating my own library/header file to handle the mappings. Right?

Yes, that is the idea.