[SDL] SDL key events and alternate graphic/combo keys
jmcoleman at gmail.com
Wed Jan 27 10:43:41 PST 2010
Probably the simplest answer would be to use the unicode character and
not worry about the keysym itself. Here's how I do it (it's kind of a
// somewhere in your init code
// where you process keyboard input
if (event.type == SDL_KEYDOWN)
switch(event.key.keysym.unicode) // BTW, if you AND this
with 0xff80 and get zero, it's an ascii character!
case '@': // each case has the resulting character
from whatever key combo is pressed
// do whatever here
On Wed, Jan 27, 2010 at 1:19 PM, Matthias Schweinoch
<matthias.schweinoch at gmx.de> wrote:
> Hi all,
> I have a problem with the keysyms reported by SDL key down/key up events:
> For any specific (physical) key on my keyboard, which has an alternate
> graphic, the keysym is always the same, regardless of the currently active
> modifier or key combo.
> On most german keyboards, ALTGR+Q should represent the AT sign @, but if I
> press this, I get a key down event for ALTGR (ok) and then another for
> SDLK_q. The same applies to US keyboard layouts: If I want to get the AT
> sign there, I would have to press SHIFT+2 (on most layouts), but again, I
> only get SDL key events with keysyms for SHIFT (left or right) and the
> numeric key SDLK_2.
> Is there some way to set SDL to consider the modifier keys when determining
> the keysym? If this is not possible, does anyone have a portable solution to
> getting the appropriate keysym for a key combo?
> Best regards,
> SDL mailing list
> SDL at lists.libsdl.org
More information about the SDL