# Digispark keyboard (only 2 keys) emulation

**URL:** <https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973>\
**Category:** Programming\
**Created:** [January 23, 2026, 7:39pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973 "2026-01-23T19:39:54Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![secretreeve](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/secretreeve/32/716131_2.png) [@secretreeve](https://forum.arduino.cc/u/secretreeve)\
**Post date:** [January 24, 2026, 2:07pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/21 "2026-01-24T14:07:08Z")

</div>

i do not have 2 unos or arduino boards to do this.

i just need a simple 2 key emulator that will plug in via usb and run off the digispark board.

as i said, i thought the whole point of the keyboard library was to emulate a keyboard, remove the need of third party software on the host

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [January 24, 2026, 2:09pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/22 "2026-01-24T14:09:56Z")

</div>

> [@secretreeve](#):
>
> i do not have 2 unos or arduino boards to do this.

Sometimes, tools and accessories are needed to play with the ideas!

---

<div class="post-metadata">

**Author:** ![secretreeve](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/secretreeve/32/716131_2.png) [@secretreeve](https://forum.arduino.cc/u/secretreeve)\
**Post date:** [January 24, 2026, 2:11pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/23 "2026-01-24T14:11:57Z")

</div>

ive been googling to try and get this resolved, and none of the search even mentions needing to go about this way.

no one else who posted so far mentioned needing more hardware or third party software.

i dont have the time or the money to go running off and buying multiple arduino boards for what should be relatively simple.

the code isnt compiling due to the errors already posted and i dont understand why

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [January 24, 2026, 2:57pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/24 "2026-01-24T14:57:07Z")

</div>

> [@secretreeve](#):
>
> ```arduino
> DigiKeyboard.h: No such file or directory
> 
> ```

To make an error free compilation of the sketch of post #3, you need to include the following library file in the sketch, which is not available in the net. I have found one (attached), but I can't include it in the IDE.

`DigiKeyboard.h`  
[DigisparkArduinoIntegration-master.zip](https://forum.arduino.cc/uploads/short-url/qxOaVb0WjkpmeHmgOT4Ugqu7ZNT.zip) (1.8 MB)

---

<div class="post-metadata">

**Author:** ![secretreeve](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/secretreeve/32/716131_2.png) [@secretreeve](https://forum.arduino.cc/u/secretreeve)\
**Post date:** [January 24, 2026, 3:00pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/25 "2026-01-24T15:00:16Z")

</div>

> [@secretreeve](#):
>
> ```arduino
> In file included from C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/DigiKeyboard.h:13:0,
> from C:\Users\ryder\AppData\Local\Temp\arduino_modified_sketch_419351\Keyboard.ino:1:
> c:\users\ryder\documents\arduinodata\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>." [-Wcpp]
> #warning "This file has been moved to <util/delay.h>."
> ^ ~~~~~~
> In file included from C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/DigiKeyboard.h:16:0,
> from C:\Users\ryder\AppData\Local\Temp\arduino_modified_sketch_419351\Keyboard.ino:1:
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/usbdrv.h:479:26: error: variable 'usbDescriptorDevice' must be const in order to be put into read-only section by means of ' __attribute__ ((progmem))'
> char usbDescriptorDevice[];
> ^
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/usbdrv.h:485:33: error: variable 'usbDescriptorConfiguration' must be const in order to be put into read-only section by means of ' __attribute__ ((progmem))'
> char usbDescriptorConfiguration[];
> ^
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/usbdrv.h:491:29: error: variable 'usbDescriptorHidReport' must be const in order to be put into read-only section by means of ' __attribute__ ((progmem))'
> char usbDescriptorHidReport[];
> ^
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/usbdrv.h:497:27: error: variable 'usbDescriptorString0' must be const in order to be put into read-only section by means of ' __attribute__ ((progmem))'
> char usbDescriptorString0[];
> ^
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/usbdrv.h:503:31: error: variable 'usbDescriptorStringVendor' must be const in order to be put into read-only section by means of ' __attribute__ ((progmem))'
> int usbDescriptorStringVendor[];
> ^
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/usbdrv.h:509:31: error: variable 'usbDescriptorStringDevice' must be const in order to be put into read-only section by means of ' __attribute__ ((progmem))'
> int usbDescriptorStringDevice[];
> ^
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/usbdrv.h:515:37: error: variable 'usbDescriptorStringSerialNumber' must be const in order to be put into read-only section by means of ' __attribute__ ((progmem))'
> int usbDescriptorStringSerialNumber[];
> ^
> In file included from C:\Users\ryder\AppData\Local\Temp\arduino_modified_sketch_419351\Keyboard.ino:1:0:
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/DigiKeyboard.h:40:73: error: variable 'usbDescriptorHidReport' must be const in order to be put into read-only section by means of ' __attribute__ ((progmem))'
> PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = { /* USB report descriptor */
> ^
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '161' from 'int' to 'char' inside { } [-Wnarrowing]
> };
> ^
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '224' from 'int' to 'char' inside { } [-Wnarrowing]
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '231' from 'int' to 'char' inside { } [-Wnarrowing]
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '149' from 'int' to 'char' inside { } [-Wnarrowing]
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '129' from 'int' to 'char' inside { } [-Wnarrowing]
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '149' from 'int' to 'char' inside { } [-Wnarrowing]
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '129' from 'int' to 'char' inside { } [-Wnarrowing]
> C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard/DigiKeyboard.h:59:1: error: narrowing conversion of '192' from 'int' to 'char' inside { } [-Wnarrowing]
> Using library DigisparkKeyboard in folder: C:\Users\ryder\Documents\Arduino\libraries\DigisparkKeyboard (legacy)
> exit status 1
> Error compiling for board ATtiny85 (Micronucleus / DigiSpark).
> 
> ```

```arduino

```

these are the errors i get regardless of what board or programmer is selected

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [January 24, 2026, 3:01pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/26 "2026-01-24T15:01:34Z")

</div>

> [@GolamMostafa](#):
>
> You need additional software at PC side to catch the key stroke going to PC a

Please. This is to emulate a USB keyboard; there are thouasands of applications that can catch keystrokes.

The OP has such an app running. It needs to hear from a keyboard over USB.

TBC: She could take a PC keyboard and plug it in and use it, except… it would be very large and leave over lotsa keys that don't need to be here.

@secretreeve - I can't help you with the digispark problem.

My keyboard emulator, which uses code only similar to what I turned up with google, runs on an old board called a trinket. It has been connected to my iMac and has two buttons and an "app selector", so I can, for example, verify an Arduino sketch by pressing a button.

I believe this is similar to what you are trying to do.

As a first step I tried my device (it's been abandoned) and I find it no longer works! I haven't run this to ground, but the other issue (for me) is that programming the trinket was always just the same kind of PITA as I found the digisparks (of old?) to be…

Other Arduino boards that are much easier to use are almost as cute and small. I sat switch away to one of them. Any USBHID ready board will do, google is your friend.

If I get a chance, I'll find my sketch. I will try to gather what is necessary to figure out why something that always worked doesn't, and suffer through re- flashing the trinket.

a7

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [January 24, 2026, 3:03pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/27 "2026-01-24T15:03:06Z")

</div>

> [@secretreeve](#):
>
> these are the errors i get regardless of what board or programmer is selected

From Tools, you --  
Tools --\> Board: ---\> ATTiycore ---\> ATtiny85 (Micronucleus / Digispark)

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [January 24, 2026, 3:03pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/28 "2026-01-24T15:03:55Z")

</div>

> [@GolamMostafa](#):
>
> To make an error free compilation of the sketch of post #3, you need to include the following library file in the sketch

_Please_.You aren't reading the posts. The @secretreeve has installed the library, and now has follow-on errors from an as-yet unresolved issue.

a7

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [January 24, 2026, 3:05pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/29 "2026-01-24T15:05:58Z")

</div>

> [@alto777](#):
>
> The OP has such an app running.

Ok! If such an app is runnng, then there is no need to develop the mediator software.

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [January 24, 2026, 3:07pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/30 "2026-01-24T15:07:56Z")

</div>

> [@alto777](#):
>
> _Please_.You aren't reading the posts.

I have tried to compile you sketch of post #3; but, it gives me the following error:

```arduino
DigiKeyboard.h: No such file or directory
Specified folder/zip file does not contain a valid library

```

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [January 24, 2026, 3:15pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/31 "2026-01-24T15:15:53Z")

</div>

@GolamMostafa

Did you install the library?

I will assume you e selected the correct board.

a7

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [January 24, 2026, 3:18pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/32 "2026-01-24T15:18:57Z")

</div>

> [@alto777](#):
>
> Did you install the library?

I don't have that Library (DigiKeyboard.h). If you or @secretreeve owning one, please forward to me.

---

<div class="post-metadata">

**Author:** ![gfvalvo](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gfvalvo/32/1013044_2.png) [@gfvalvo](https://forum.arduino.cc/u/gfvalvo)\
**Post date:** [January 24, 2026, 4:01pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/33 "2026-01-24T16:01:44Z")

</div>

> [@secretreeve](#):
>
> program up a digispark board that will emulate itself as a 2 key keyboard

My understanding is that board emulates a USB interface with bit-bang software. Not having used it nor a ATtiny85 processor, I can't help with your current problem. But if you can't get it to work, I'll suggest an alternative. Use a board based on the 32u4 processor such as [This One](https://learn.adafruit.com/introducting-itsy-bitsy-32u4/). The 32u4 has a native hardware USB interface so it will work with the the [Standard Arduino Keyboard Library](https://github.com/arduino-libraries/Keyboard). It also has a separate hardware UART that you can use at the same time as the USB port for debugging or I/O. This solution won't be quite as compact as what you're trying to do and will require a USB cable between the 32u4 and the laptop. However, I think it will be more powerful and flexible.

PS - [Here is a 32u4-based board](https://www.ebay.com/itm/132474485092) that would not need a USB cable to the laptop.

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [January 24, 2026, 4:14pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/34 "2026-01-24T16:14:42Z")

</div>

Yeth. The board @gfvalvo kindly linked

> What's smaller than a Feather but larger than a Trinket? It's an ItsyBitsy!

will work and is probably not so fussy to use as either digispark or the trinket.

Around my kab, all digisparks and trinkets are permanently deployed after the heroic struggle which was getting a sketch into them that could let them just live out their lives w/o needing to be flashed again…

YMMV

a7

---

<div class="post-metadata">

**Author:** ![secretreeve](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/secretreeve/32/716131_2.png) [@secretreeve](https://forum.arduino.cc/u/secretreeve)\
**Post date:** [January 24, 2026, 4:15pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/35 "2026-01-24T16:15:43Z")

</div>

i decided to go a different route to the digispark and ordered an arduino micro/pro with a 32u4 chip and found a feed about “hid-project”

luckily the remote housing i had already 3d printed is easily modifiable to take the micro/pro.

the new code compiled with respect to that board without any issues. i may well look into developing this further to add a job stick into the top of the remote for axis control during setup of the machine.

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [January 24, 2026, 4:17pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/36 "2026-01-24T16:17:29Z")

</div>

> [@secretreeve](#):
>
> the new code compiled

What code? Say if it's here or post it.

I am advising myself to stop messing with the old trinket. But I am stubborn. 😑

a7

---

<div class="post-metadata">

**Author:** ![secretreeve](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/secretreeve/32/716131_2.png) [@secretreeve](https://forum.arduino.cc/u/secretreeve)\
**Post date:** [January 24, 2026, 4:21pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/37 "2026-01-24T16:21:41Z")

</div>

```arduino
#include "HID-Project.h"

const int switch1 = 1;
const int switch2 = 2;

int FinderView = 0;

void setup() {
  pinMode(switch1, INPUT_PULLUP);
  pinMode(switch2, INPUT_PULLUP);
 
  Keyboard.begin();
  Consumer.begin();
}

void loop() {

  if(!digitalRead(switch1)) {

    Keyboard.press(KEY_LEFT_ALT);
       Keyboard.press('r');

    Keyboard.releaseAll();

    delay(300);
  }

  if (!digitalRead(switch2)) {

    Keyboard.press(KEY_LEFT_ALT);
    Keyboard.press('s');

    Keyboard.releaseAll();

    delay(300);
  }
}

```

as requested, i appreciate you stepping in on this thread alto, you’ve helped me before with previous projects and your assistance is always valueable.

with this code, which was pretty much stolen and adapted from an instructables thread, i’d be unsure how to “hold” a key for extended. im fairly sure it would be changing the “if” so it had an “else” to register the button release.

of course, using delay in code isnt ideal, however for a basic beginning, where the only 2 functions is to send “start” and “stop” commands, its acceptable.

also, my apologies for being the cause of you digging out the trinket lol

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [January 24, 2026, 4:34pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/38 "2026-01-24T16:34:25Z")

</div>

> [@secretreeve](#):
>
> also, my apologies for being the cause of you digging out the trinket lol

LOL, no problem.

The code you posted is very simple.

Here's a perfect case for two paths forward.

1.Take an opportunity to learn button handling which would include debouncing and state change detection. Both are key concepts in this world, and worth knowing about even if only as a challenge because…  
  
  
2. you could use a button library, _ezButton_ (small e small z Button) for example, which could cut this like butter with a chainsaw.

The key point in either is it would let you do one thing when the button became pressed, and another when the button got released.

Currently, if you read the code, you see the key stroke happens when you press the button, and the key release happens 300 milliseconds later, no matter your fat finger got off the button 200 milliseconds earlier.

If you keep the button down, you will cause another stroke/release pair to be launched, a repeat at ~3 Hz.

When I get to the lab I'll find a gentle _ezButton_ sketch if you haven't by then.

a7

---

<div class="post-metadata">

**Author:** ![secretreeve](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/secretreeve/32/716131_2.png) [@secretreeve](https://forum.arduino.cc/u/secretreeve)\
**Post date:** [January 24, 2026, 4:38pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/39 "2026-01-24T16:38:58Z")

</div>

id be highly interested in looking at the ezButton sketch for sure.

so if im understanding your responce right and the code correctly,

the code cycles looking for a button high signal, as soon as its detected then it activates the remainder of the selected buttons code and ignores the second buttons code. the delay only comes into play in order to give you time to release the button and the code go back to scanning for button press signals.

so if im right in that, you could just hold the button and the code will repeatedly cycle that section and just consider it “prolonged button press”

is that right?

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [January 24, 2026, 5:38pm UTC](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973/40 "2026-01-24T17:38:59Z")

</div>

edit: I see I myself did not read the code carefully... each button actually presses down two keys!

So the release thing is shorter than explicitly letting go of the twopressed keys.

I said too quickly:

> [@secretreeve](#):
>
> prolonged button press

No. If you look, the button causes two things, it sends a keystroke:

```arduino
       Keyboard.press(KEY_LEFT_ALT);
       Keyboard.press('r');

```

then it sends a command to release all keys, which naturally here includes and consists entirely on the one key that is down:

```arduino
    Keyboard.releaseAll();

```

It might be clearer had the author sent the correct command to release the single key she knew she had caused to go down, but it is harmless to be general and means less thinking if a time comes for handling combo keystrokes.

The delay is indeed for you to get off the key. Holding it down means when the delay finiches the loop comes around again and you get another key down and key up, which is different to holding a key down.

When you hold down a real key on a real keyboard, usually you get one character, some first longish delay, then the same character sent again at a higher rate, autorepeat.

So in practice it kinda the same, but the subtle and careful (_cough_!) UI design of a long delay before rapid additional keystrokes is frustrated, and you get 3 characters per second, same time between first to second as from any subsequent Nth and N+1th keystrokes.

a7

> [@secretreeve](#):
>
> ```arduino
> Keyboard.press(KEY_LEFT_ALT);
> Keyboard.press('r');
> 
> Keyboard.releaseAll();
> 
> ```

[Previous page](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973.md?page=1)

[Next page](https://forum.arduino.cc/t/digispark-keyboard-only-2-keys-emulation/1426973.md?page=3)
