Problems Sending Signals to the Arduino-Uno via Keyboard I have an Arduino Uno and a usb 2.0 shield in which I connected a keyboard to. I have all the necessary libraries installed but what I am trying to figure out is how to light an led when I press a specific key.
I am new to codding Arduino boards and I have done a lot of reading but I cant figure out my issue I feel like if I get this figured out I will be a lot better off in my future projects.
#include &lt;hidboot.h&gt;
#include &lt;usbhub.h&gt;
#ifdef dobogusinclude
#include &lt;spi4teensy3.h&gt;
#endif
#include &lt;SPI.h&gt;

int SKEY = 8;

class KbdRptParser : public KeyboardReportParser
{
    void PrintKey(uint8_t mod, uint8_t key);

  protected:

    void OnKeyDown  (uint8_t mod, uint8_t key);
    void OnKeyUp    (uint8_t mod, uint8_t key);
    void OnKeyPressed            (uint8_t key);
};

void KbdRptParser::PrintKey(uint8_t m, uint8_t key)
{
  MODIFIERKEYS mod;
  *((uint8_t*)&amp;mod) = m;
  Serial.print((mod.bmLeftCtrl   == 1) ? &quot;C&quot; : &quot; &quot;);
  Serial.print((mod.bmLeftShift  == 1) ? &quot;S&quot; : &quot; &quot;);
  Serial.print((mod.bmLeftAlt    == 1) ? &quot;A&quot; : &quot; &quot;);
  Serial.print((mod.bmLeftGUI    == 1) ? &quot;G&quot; : &quot; &quot;);

  Serial.print(&quot; &gt;&quot;);
  PrintHex&lt;uint8_t&gt;(key, 0x80);
  Serial.print(&quot;&lt; &quot;);

  Serial.print((mod.bmRightCtrl   == 1) ? &quot;C&quot; : &quot; &quot;);
  Serial.print((mod.bmRightShift  == 1) ? &quot;S&quot; : &quot; &quot;);
  Serial.print((mod.bmRightAlt    == 1) ? &quot;A&quot; : &quot; &quot;);
  Serial.println((mod.bmRightGUI  == 1) ? &quot;G&quot; : &quot; &quot;);
};

void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
{
  Serial.print(&quot;DN &quot;);
  PrintKey(mod, key);
  uint8_t c = OemToAscii(mod, key);

}

void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key)
{
  Serial.print(&quot;UP &quot;);
  PrintKey(mod, key);
}

void KbdRptParser::OnKeyPressed(uint8_t key)
{
  Serial.print(&quot;ASCII: &quot;);
  Serial.println((char)key);
};

USB Usb;
HIDBoot&lt;USB_HID_PROTOCOL_KEYBOARD&gt;    HidKeyboard(&amp;Usb);

KbdRptParser Prs;

void setup() { 
 
 Serial.begin(9600);
#if !defined(__MIPSEL__)
  while (!Serial); 
  Serial.println(&quot;Start&quot;);

  if (Usb.Init() == -1)
    Serial.println(&quot;OSC did not start.&quot;);

  delay( 1 );

  HidKeyboard.SetReportParser(0, &amp;Prs);

}

void loop() {
 Usb.Task();
}

Anyways I know how to make if statements and how to activate pins on the Arduino but I cant figure it out in this keyboard library. For now I just made it print &quot;TRUE&quot; since there is not need to get complicated if I cant get the first step to work. Before I made that if statement the serial monitor would show the value assigned to the key and label it DN # and when I let up on the key it would say UP # but how can I translate that to sending a pulse to whatever pin when I push a key and stop sending a pulse when I let up on the key?
Also in my if statement that I made I know I need something before == sign but I tried multiple things and they did not work so I just left it blank and the reason I used the number 16 was because that was the value assigned to the S key in which I wanted to use to light an led. Anyways any help would be greatly appreciated!
Keyboards cannot be used quite like you wish - the keyboard will send a key (scan) code when a key is pressed and then repeat that code if the button continues to be pressed. There is a different code sent when the same key is released.

The scancode for key release is obtained from it by setting the high
order bit (adding 0x80 = 128). Thus, Esc press produces scancode 01,
Esc release scancode 81 (hex).  For sequences things are similar:
Keypad-/ gives e0 35 when pressed, e0 b5 when released. Most keyboards
will repeat the make code (key down code) when the key repeats.

From: https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html