digistump / DigisparkArduinoIntegration

DEPRECATED - REPLACED BY: https://github.com/digistump/DigistumpArduino
281 stars 330 forks source link

Weird double output with DigiKeyboard.h #29

Open mateeees opened 2 years ago

mateeees commented 2 years ago

Hi, I have a really weird problem, I don't know if it is my code or it is a bug. When I use DigiKeyboard.sendKeyStroke or DigiKeyboard.print it always prints the output a second time after a second or two. Also when I upload the code onto the digispark, disconnect it, and connect it again it just randomly prints the output.

An example: (I am trying to open Spotify using macropad) DigiKeyboard.sendKeyStroke(0, MOD_GUI_LEFT); DigiKeyboard.delay(1000); DigiKeyboard.print("spotify"); DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(KEY_ENTER);

It prints "spotify" twice, and also when I plug in the digispark. It is so random. Thanks in advance.

ghost commented 2 years ago

DigiKeyboard.sendKeyStroke() function is used for pressing keys on the keyboard. DigiKeyboard.print() function is used to write what you want.

Check macropad key programming if it has some issues, because the sketch you provided is for windows keyboard.

To open Spotify, the sketch should like -

include

void setup() { DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(0,MOD_GUI_LEFT); //This keystroke is for press windows key only DigiKeyboard.delay(1000); DigiKeyboard.print("spotify"); DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(KEY_ENTER); } void loop() { //Nothing to run here }

Thank You