Key callback sometimes reports key == -1 for all function keys

Thank you for reporting this! It is indeed a bug in GLFW, with a PR in the process of being merged.

The PR works but is specific to the evdev keycode set so I’m expanding it right now. If you’re on a modern Linux system it will likely work for you without modification but it won’t yet on servers like Cygwin/X or on some non-PC hardware.

The function keys likely only have a single group. The existing code in GLFW incorrectly assumes that every key has the same number of groups but in XKB this can vary per key. You can see the XKB version your setup with xkbcomp -o myfilename.txt $DISPLAY.

GLFW needs to use XKB to be able to map GLFW_KEY_* constants to physical keys, as key symbols vary between layouts. The core protocol only provides undifferentiated keycodes.

1 Like