https://web.archive.org/web/20130728100527/http://www.libsdl.org:80/docs/html/sdlkey.html
Here are the key enums listed in the SDL documentation. Specifically for this question we only need a subset.
SDLK_COLON //value is 58 (ascii)
SDLK_SEMICOLON //value is 59 (ascii)
//Code Example illustrating question
void KText::OnKeyDown(SDLKey key, SDLMod mod, Uint16 unicode) {
if(key == SDLK_COLON) exit(1);
}
When I hit semicolon, clearly it won't exit. When I hold shift and hit semicolon (keying a colon) it still doesn't exit. I've tested, no matter if I'm holding shift or not it throws the default key. This could be by design or it could be a bug. I could simply say well, if I'm holding shift and key semicolon then I should use colon instead. However that seems rather a pain to remap all the keys while holding shift.
Has anyone else found a work around for this?
Edit:
Looking at values inside the function for key indicate the key is the same regardless of holding shift or not and it's not specific to semicolon/colon. It's the same for all keys (makes sense for letter keys sense there is no SLDK_A only SDLK_a, but for brackets, quotes, greater than/less than, dollar sign, etc they do not show up only the base key)
So, after much commenting back and forth: To correctly read the keyvalue, the unicode
value should be used, which means SDL_EnableUNICODE(1);
somewhere in initialization of the program (so that unicode
gets filled in - it does add a tiny bit [in most cases, it's function call to a function that performs a lookup in a table of some sort, but it may be a little more than that] of extra processing, so if it's not needed, it's wasted to try to translate every keypress to their respective actual unicode value).