I have built GLFW from source on Linux, commit 6aca3e99 (master~4 at the time of writing).
It mostly works as intended, but I can consistently reproduce one issue if I start my application after changing the keyboard layout via XFCE’s keyboard shortcut. If I do that, pressing any function key will deliver a key value of minus one in the key callback.
More precisely, my standard configuration has a two keyboard layouts: SE (default) and US. If I stay in the default layout, no problem (pressing escape will deliver key==256 for instance). But if I toggle the keyboard layout to US via the configurable XFCE keyboard shortcut or by pressing the xfce4-xkb-plugin button, and then start my application, I systematically get the problem: the key callback delivers key==-1 for all function keys. Non-function keys still seem to work fine. When in that state, switching back to SE layout does not come around the issue. Please note that what I am using here is as far as I know the standard way to toggle the keyboard layout in XFCE.
However, the US layout is not a problem in itself. If, instead of using the XFCE utilities, I change the keyboard layout by typing
setxkbmap us in a terminal and start my application after that, everything works fine.
I have therefore tried to understand the difference in state between these two procedures, and I have found one: when I use
setxkbmap us (or
setxkbmap se for that matter), my double-layout is disabled, which it is not when I use XFCE utilities:
setxkbmap -query shows
layout: se,us after XFCE layout switch, but shows
layout: us or
layout: se after the keyboard switch.
So it seems to be the combination multiple keyboard layouts + non default layout selected, that triggers the issue.
At last, it could be worth mentioning that the
scancode always seems to be correct (the problem is only with the
Since GLFW seems like a very good cross-platform library, I hope there exists a solution for this problem.
Thanks in advance for any help.