Skip to content

press key but do not release? #36

@AddaxSoft

Description

@AddaxSoft

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions