Keyboard

Hi there so trying to use my pro micro to received keys via serial then send them back as a keyboard
dunno if im missing something but it just will not work the way i need

#include <Keyboard.h>


void setup() {
	Serial.begin(9600);  
}
 


void loop() {
	if (Serial.available() > 0) {
		
		 byte key = Serial.read();//Key
		 Keyboard.write(key);// Will not work
		 Keyboard.write('A');// Works 
	}  
	delay(100);
	
}

How did you setup your serial console ?

Usually one adds a Keyboard.begin(); in the setup as well (even if it’s useless at the moment)

#include "Keyboard.h"

void setup() {
  Serial.begin(115200);
  Keyboard.begin();
}

void loop() {
  if (Serial.available() > 0) {
    char c = Serial.read();
    Keyboard.write(c);
  }
}

Are you getting NO keyboard input or just the wrong keyboard input?

The library example KeyboardSerial does almost the same thing. It uses type 'char' instead of type 'byte'. Perhaps that is significant.

I’m more wondering if OP’s console is at 9600 bauds and not sending \r\n....

Thanks for the helps guys still not got it working the way i wanted but appears to be something to do with how my c# app is sending data
as using arduino to send same data and it works