What are the codes for the brightness control keys?

My laptop has brightness-up and brightness-down keys that control the brightness of the screen. What are the names of those key codes? (It has them as alternative functions on F5 and F6, fwiw.) I browsed through https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_consumerctl.h and related files, but didn’t see anything corresponding to brightness control.

I think this may depend on the hardware, the OS, or both.

1 Like

I just did some searching, and found that the QMK documentation offers some help. On my iMac, two regular HID Keyboard keys will control the brightness Key_ScrollLock & Key_Pause (I guess Apple figured it was about time to use those keycodes for something useful).

There are also Consumer Control keys that will do it—but those are not defined in the official USB HID Usage Tables, which is what Kaleidoscope’s keycodes are based on. I tried them out anyway, by adding these two lines to key_defs_consumerctl.h:

#define Consumer_BrightnessUp CONSUMER_KEY(0x6f, HID_TYPE_OSC)
#define Consumer_BrightnessDown CONSUMER_KEY(0x70, HID_TYPE_OSC)

Both keys worked fine when I tested this out on mac OS (Catalina). According to the QMK docs, these keycodes also work on Linux and Windows. I’m more confident in the former, since that’s where I found the actual keycode values in the source code.

3 Likes

Thanks! The latter works for me :slight_smile:

I submitted a PR to add these two keys, in case anyone else wants to use them for the moment. @jesse pointed out that a new version of the HID tables was published just a month ago, and that includes these, and many other additions. That PR won’t be merged in its current form, because we’ll fix things more comprehensively in KeyboardioHID and Kaleidoscope, but in the meantime, it could be useful to anyone who wants them right now.

2 Likes

Following up: There’s now another PR, this time with all of the new Consumer Control & System Control keys from version 1.2 of the HID Usage Tables. Following naming conventions, the new names of these keys are:

Consumer_DisplayBrightnessIncrement
Consumer_DisplayBrightnessDecrement
4 Likes