HID keyboard key codes

i am trying to use my Arduino Uno as a HID Keyboard. i saw a youtube video in which the guy uses arduino uno, flashes a keyboard firmware and when pressing a button, the arudino works as a keyboard. i also did the same thing with my arduino uno and everything WORKS FINE BUT the youtube guy provided an image which has keycodes for almost all keys. but i need keycodes for more keys. i cannot find them anywhere that match this guy's image and works for my arudio. i need key codes for volume+, volume-,mute. only three. here is that image :


credit for image and code : Eward Hage


uint8_t buf[8] = { 0 };   //Keyboard report buffer

#define PIN_W 2 // Pin for w

void setup() {
  Serial.begin(9600);

  pinMode(PIN_W, INPUT);

}

void loop() {
  if (digitalRead(PIN_W) == 1) {
    buf[2] = 26;
    Serial.write(buf, 8);
    releaseKey();
    delay(100);
  }


}
// Function for Key Release
void releaseKey()
{
  buf[0] = 0;
  buf[2] = 0;
  Serial.write(buf, 8); // Send Release key
}

Are the keys volume+, volume- and mute - part of standard PC keyboard? If it are additional keys - it key codes can be varied from one keyboard manufacturer to another.
The solution may be to read the scancodes directly from your keyboard using a separate program, for example for Windows
https://www.nirsoft.net/utils/keyboard_state_view.html

sir, in that software, it shows the following results(image):
image
but when i use these in my arduino, it doesnt control volume :frowning_face:
btw, thanks for letting me know abt the software

when i do the changes and set 175 for volume up, the arduino sends these codes to the PC as shown in image
image
the software cannot name this and the name of key is blank. i think, for arduino uno, the key codes are read differently by computers. sir please help me :sob:

It seems to me that your keyboard has the specific driver that handles of non-standard scancodes... but this driver does not recognize the arduino as compatible device.

so what should i do??
i am a newibe and a noob

USB key codes for the keys you want:

Dec Hex Key name
127 0x7F Keyboard Mute
128 0x80 Keyboard Volume Up
129 0x81 Keyboard Volume Down

The full list is in this document:

1 Like

Thank You so much sir !!!!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.