View Full Version : SDL shift+some key question?
WhatMeWorry
2006.09.19, 03:52 AM
case SDL_KEYDOWN:
{
switch( event.key.keysym.sym )
{
case SDLK_ASTERISK:
{
// whatever
}
break;
I'm trying to "capture" the asterisk key on my keyboard, but
even.key.keysym.sym has the SDLK_LSHIFT (as I'd image it should,
but how do I then get the * symbol?
Sorry if this is already answered somewhere, but I poked around and
can't find anything.
Taxxodium
2006.09.19, 04:49 AM
would this work?
case '*':
//whatever
break;
akb825
2006.09.19, 05:19 AM
It doesn't automatically apply the shift modifier to the key. (it's actually better that way, since in a game you would usually want shift treated like any other key) In order to test for *, you're going to have to see wen the character is '8' and the shift key is pressed. (you can use a macro to check for both shifts at once, not just the left)
sealfin
2006.09.19, 05:21 AM
I've run into this problem (albeit with a slightly older version of SDL); I never solved it satisfactorily, but I avoided it by having my own flag for the SDL_LSHIFT and SDL_RSHIFT keydown events, and referring to those flags when the app received an SDL_8 keydown event; an ugly hack, as it won't work correctly on any keyboard with a different layout :\
Nickolei
2006.09.19, 06:41 AM
If you enable unicode translation using SDL_EnableUNICODE(true) then you should be able to directly compare to an arbitrary character.
switch(e.key.keysym.unicode)
{
case '*': //or you can use SDLK_ASTERISK, it's the same thing
//do it to it.
break;
}
Remember SDL will send you a key down event for the shift you'll want to ignore if you're not.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.