zigalenarcic / mangl

An enhanced man page viewer for linux and BSD systems based on OpenGL and mandoc libraries
Other
39 stars 7 forks source link

translate characters for keyboard input #5

Closed omar-polo closed 2 years ago

omar-polo commented 2 years ago

keys returned to glfwSetKeyCallback are physical keys, i.e. they correspond to the position on the US QUERTY layout, not the character from the keyboard layout currently in use. Need to call glfwGetKeyName to obtain a string reperesting what key the user actually intended to use.

Spotted while trying to add the bindings for C-v/M-v (and while testing your latest commit adding those) as I'm using a (modified) dvorak layout. This explain why I wasn't able to use the various control- keys in mangl. (for e.g. "v" in the dvorak layout is where there is a dot in a standard querty layout)

see also: https://github.com/glfw/glfw/issues/114

omar-polo commented 2 years ago

Oh, I have to specify that I don't have the slightest idea of whether this "hack" of looking at the "keyname" is ok or not. I'd just like to being able to ctrl-f etc. regardless of the keyboard layout I'm using :)

(TBF: for GLFW it makes sense to use physical keys; if you think about it various games are designed to use some keys -- think of WASD for example -- regardless of the actual keyboard layout.)

zigalenarcic commented 2 years ago

I think it is good. It should work without problem everywhere. Thanks!

omar-polo commented 2 years ago

thanks :)