Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Maybe other VM's don't actually simulate the keyboard LEDs?
Have you tried running it on actual hardware? Last time I checked (a while ago) what you're doing is correct.
Depending on your system and the emulator, the actual keyboard LEDs won't be changed.
For example, at the bottom of the GUI on Bochs, there are initially greyed out "NUM", "CAPS", and "SCRL". Setting the LEDs on the keyboard should change these, not the actual LEDs on your own keyboard. This is with the Win32 GUI for Bochs, I don't have a linux box with X installed since I only use it for development and number-crunching, so I don't know if the X GUI is the same. It is probably similar. I am not sure about the interface with other emulators. QEMU running under windows with the SDL interface doesn't have any indicators onscreen, and I don't have code in my OS for setting the keyboard LEDs right now so I'm not testing it.