
Then I set about mapping the scancodes to key names -- so it can also tell me a textual name of each key. I mapped every key for the four keyboards I have here and made separate keymaps for US and UK keyboards. It seems to work really well.
But then I did a bit of web searching to see if the special keys on some keyboards (e.g., Sleep, Wake up, Play/Pause, Mute, Vol up/down, Internet, etc.) had standard codes, and I came across *this* page: http://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html. If I've understood this right, there are three scancode sets, and sets 1 and 3 are sometimes buggy.
To my horror, my keymaps seem to be set 1. But they also seem to be the same as the "X (Set 2)" column in that table, and I don't know what that is. Now I'm just really confused. Can anyone tell me, for best compatibility should I switch the keyboard to another set and redo the maps? Is there a set which is always supported by keyboards or do I need to write code to handle all of them?
Is it also a good idea to set up an enum of virtual key constants so I can refer to them in the rest of the OS instead of hardware-locked scancodes? I reckon that's what I should do next, but I'd like to hear advice from the more experienced first.
(Honestly, I never realized keyboards were so complicated!)