Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

press key but do not release? #36

Open
AddaxSoft opened this issue Aug 1, 2024 · 0 comments
Open

press key but do not release? #36

AddaxSoft opened this issue Aug 1, 2024 · 0 comments

Comments

@AddaxSoft
Copy link

I'm currently working on a project using a Digispark microcontroller (based on the ATTiny85) and the DigiKeyboard library to emulate a USB keyboard. My goal is to send three (piano) keys simultaneously (e.g., 'K', 'X', and 'A'), but I'm facing some difficulties.

#include "DigiKeyboard.h"

void setup() {
  DigiKeyboard.delay(5000); // Give time for the system to recognize the device

  // Pressing multiple keys
  DigiKeyboard.sendKeyPress(KEY_K);
  DigiKeyboard.sendKeyPress(KEY_X);
  DigiKeyboard.sendKeyPress(KEY_A);
  DigiKeyboard.delay(1000); // Hold for a second

  // Releasing keys
  DigiKeyboard.sendKeyRelease(KEY_K);
  DigiKeyboard.sendKeyRelease(KEY_X);
  DigiKeyboard.sendKeyRelease(KEY_A);
}

void loop() {
  // No continuous actions needed
}

but I see each time I call sendKeyPress() the previous key gets released. Anyway I can keep it pressed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant