1
\$\begingroup\$

If I poll keyboard events with SDL2 all I get is the pressed key and the modifiers. But I am using Neo and have some keys like Esc and arrow keys on a different layer which means that e.g. Mod4+i is the same as the left arrow key.

How can I get the modified key from SDL2?

The same problem occurs to me when I want to handle special chars which are located on different keys on different keyboard layouts (/ for example has a dedicated key on US layout while on German layout it is located at Shift+7).

I already found the text input mode, but this seams rather unfitting as one gets a string instead of a single key.

Edit: formatting

Edit 2: I just found another problem .. SDL doesn't recognize Mod4 so when pressing Mod4 plus another key, the mod field is still 0. Other modifiers like Shift work.

\$\endgroup\$
  • \$\begingroup\$ Have you tried using scancodes? I feel like they might solve atleast some of your problems. \$\endgroup\$ – Tyyppi_77 Sep 8 '16 at 18:49
  • \$\begingroup\$ But that way I have to handle different keyboard layouts different ... Edit: Also Mod4 is not recognized which doesn't allow me to handle this by hand. \$\endgroup\$ – Daniel Hauck Sep 8 '16 at 18:51
  • \$\begingroup\$ I'm not at all familiar with Neo (the website is in German), but it does seem a little weird that SDL doesn't recognize the modifiers. Could you perhaps clarify how Neo works, and where in terms of event managing it does its magic? \$\endgroup\$ – Tyyppi_77 Sep 8 '16 at 18:56
  • \$\begingroup\$ I can only speak for Linux ... there it is an official XServer keyboard map using the Xkbmap levels (I'm not really familiar with how the XServer handles different levels), so it should be no magic. \$\endgroup\$ – Daniel Hauck Sep 8 '16 at 19:06
  • \$\begingroup\$ What's your SDL version? \$\endgroup\$ – Tyyppi_77 Sep 8 '16 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.