I am using GLFW for the input in my game. I just started learning it and I have encountered a problem. The problem is the input, I have a callback function, where I check for keypresses. I want the program to toggle wireframe mode when the user press 1, therefore I have this code:

if(key == '1' && action == GLFW_PRESS)
    wireframe = !wireframe;

The problem is that I am Czech and we obviously have different keyboard layout - I use english keyboard layout for programming and when I press 1 it works, however, when I press the same key on czech layout it doesn't work, probably because we have to press Shift along with the '1' key to actually get the 1 on the screen. It may seem obvious that it does not work, but when I used SFML it worked.

I also tried replacing the '1' with 49 or 0x0031, but the result is the same.

Is there a solution or do I have to set the layout manually by the system API?

Thanks in advance.

  • \$\begingroup\$ Why don't you print the whatever is pressed to find out the code for your key? \$\endgroup\$
    – Luke B.
    Commented Feb 10, 2013 at 15:18
  • \$\begingroup\$ Of course I tried, it prints nothing when using CZ layout, when using EN layout it prints true/false. But thank you! \$\endgroup\$
    – michy04
    Commented Feb 10, 2013 at 18:34

1 Answer 1


What I think happens is that a unicode int gets passed when you have your Czech layout.

(What I'm not sure is how the int get's passed as a char . . .)

If you use xev in the terminal, a window will pop out and input info will print in your terminal when you click/move/drag keys or your mouse.

This is a good way to check what the difference between '1' in US layout and '1' in Czhech layout.

There might be a better way to doing this, but otherwise I would suggest to create a table from your xkbmap manually or make a script that gets that info and automatically makes an array from it.

That's all I know, but good luck!

  • \$\begingroup\$ Thank you! How come I did not figured it out? Anyway, it helped, not that it would solved the problem, however now I know, that if I press the key on EN layout it returns 49(code for 1), but when I press the key on CZ layout it returns 43(code for +, which is the key that is returned on CZ layout when you press 1 without holding shift.) So this is the problem, you solution is useful I already thought of it, but it seems way too "enforcing" solution. I believe there is a better one. I'll wait if anyone will come up with better one, otherwise I'll mark your answer as the solution. Thank you! \$\endgroup\$
    – michy04
    Commented Feb 10, 2013 at 18:32
  • \$\begingroup\$ No problem, glad it helped =) \$\endgroup\$
    – Yuuta
    Commented Feb 10, 2013 at 22:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .