Sam Lantinga wrote:
>> I also just noticed that using my definition of SDL_* we would never get
>> a SDL_KP_1 because you only get those when the num lock key is locked.
> That's actually a really good point. There are some keys like numlock and
> the fn key that modify the actual behavior of keys. For example, when numlock
> is on, the keypad 4 key generates '4', but when it's off, that same physical
> key generates a left arrow key.
> How in the world does that fit into our model? :)
> I think most operating systems modify the virtual key that is generated by
> the physical key based on the numlock state, e.g. VK_KP4 vs VK_LEFT
> (not confirmed because my web access is down atm)
Here's how these things work on the Mac:
- Mac OS does not have the concept of "num lock". The keypad keys always
type numbers, they never act as arrow keys. The key that acts as "num
lock" on Windows acts as "clear" on Mac OS, and is labeled as such on
Apple keyboards. (That's why I called its physical key code
My opinion is that, also on Windows and X11, the keypad keys should
always have physical key codes SDLK_KP_1 etc., whether or not num lock
is enabled. I would even make their layout key codes (and therefore key
names) always be the numbers (in fact, I have explicitly done that in my
current X11 implementation). But, being a Mac guy, I may be biased.
- Apple portables have a "fn" key that is used to fake a 105-key
keyboard with 79 actual keys. It acts at a lower level than SDL
currently accesses the keyboard, and in my opinion that is the right
thing to do (I don't even know if it would be possible to do otherwise).
I.e. the physical key code of the U key is SDLK_U, but the physical key
code of fn-U is SDLK_KP_4. fn itself does not generate SDL key events
(though that would be possible, it has a Mac OS virtual key code).
- Apple portables have a key labeled "num lock", but it has absolutely
nothing to do with the "num lock" key on PC keyboards. It would be best
described as a partial "fn-lock". It too is part of the scheme to fake
more keys than are actually there, and operates below SDL's radar.
SDL mailing list