Basically there is nothing super hard in it. The only discovery for me was that the fn does not throw any signal to X by itself. It works only in combination with some other key. To test that you can run xev (listens events from keyboard/mouse and prints them) in your terminal and press fn several times.
Now let’s try combination - fn+F2 for instance - volume down for my DELL laptop. You’d see something like this in terminal:
The interesting part here is keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume). To refer to this combination in rc.lua we need keycode with hash - #122. So for volumes fn keys combination the key mapping would be like this:
And for brightness level:
Another way to get keycodes of key combinations is to list them using following command: xmodmap -pke and then grep them, for example: xmodmap -pke | grep Brightness.