Sign in to follow this  
Lode

Key codes in SDL

Recommended Posts

I experimentally saw that the SDL key codes are ascii codes, e.g. 'a' is the same as SDLK_a. But keys on the keyboard have two symbols on them, e.g. = and + are on the same key. But + requires pressing shift. And in SDL the shift is a modifier, and = the ascii code. How exactly does the reasoning behind these ascii codes to identify pressed keys work? Does it use the ascii code of the symbol that is gotten when NOT pressing shift? If so, should a '+' be detected by detecting if the key with ascii code '=' is pressed in combination with shift? But how does this behave on other keyboards than qwerty if the OS or the SDL implementation for that OS doesn't convert from qwerty to e.g. azerty? (see my remark about linux vs windows below) In fact I was trying this with an azerty keyboard instead of a qwerty keyboard myself, and the + key is also behind shift on an azerty, and I was unable to get events of this key when using '+' as key code. And to add more to the confusion, in Linux the "a" matches the "a" on my azerty, while in Windows, even though the unicode key events of SDL work correct for azerty there, for the key syms, "a" and "q" are swapped in Windows with SDL 1.2... Sorry if the post above is confusing, I'm half posting my experimental results and half asking a question how exactly it works...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this