Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Character callback with modifiers that is ALWAYS invoked for chars with pressed mods #1618

christianparpart opened this issue Jan 4, 2020 · 2 comments


Copy link

@christianparpart christianparpart commented Jan 4, 2020


It is currently not possible to receive character events with modifiers for all characters that were typed in.

My demo was: A user is typing in Ctrl+[ in standard (en_US) keyboard layout works just fine with key as well as char callback but if you use (for example) de_DE (German[y]) keyboard layout, then in order to send a Ctrl=[, what the user has to press is Ctrl+AltGr+8. This is captured by the key callback as Ctrl+Alt+8 (which is not helpful because the user app itself SHOULD NOT re-implement keyboard layout mapping nor do I know what keyboard mapping the user has) and more importantly, the character callback is not invoked for that, neither is the character-with-modifier callback being invoked for that.

My request basically is to let the character-with-mods callback know about ALL characters being typed in with all modifiers - it also feels like a bug to me that this callback isn't invoked on non-en_US keyboard layouts (my test-case: de_DE), so I'm not sure it actually is a bug or a feature request.

p.s.: I didn't find any resource telling me why glfwSetCharModsCallback is being deprecated. It seems this is the only function that makes sense for me to use (even though it's currently not really fully working); maybe someone knows where to look at for this decision?

Many thanks in advance,


This comment has been minimized.

Copy link

@dougbinks dougbinks commented Jan 5, 2020

If you take a look at the issues for glfwSetCharCallback you'll see that it didn't work for the use-case you've described.

Basically a key press such as CTRL+ALT+8 will not result in a character, so there will be no call to glfwSetCharCallback nor to glfwCharCallback. This is not because GLFW is doing something to remove it, but because no character exists to represent this key combination.

However, the key combination ALT+8 does represent a character, [ for the keyboard layout in your example.

So the solution I proposed on the forum is that we need to extent glfwGetKeyName to be able to handle translations in the presence of modifier keys. So the new version would be something like:

const char* glfwGetKeyName ( int key, int scancode, int mods );

Note that glfw would either have to ignore the CTRL mods, or users of the API would need to know that CTRL as a mod will result in no character. I would prefer the later as being more obvious.


This comment has been minimized.

Copy link

@christianparpart christianparpart commented Jan 5, 2020

Many thanks for clarifying.

@elmindreda elmindreda added the input label Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.