Closed inkeliz closed 4 years ago
We could implement a function engo.GetKeyName(k engo.Key) string
that returns the character when passed a Key. So, you could say "Press " + engo.GetKeyName(key) + " to go up". That should be able to print W on QWERTY and Z on AZERTY and so on
It seems a nice design, and I like the engo.GetKeyName(k engo.Key) string
. But I think it will be difficult than I thought.
I couldn't find any "key mapping" that matches all keys based on the US-Keyboard. There are also too many layouts, like the Brazilian one (ABNT-2) uses the QWERTY, initially, but has keys like "ç" and accents in other places. If you try to change your keyboard-layout on Windows there's too many layouts...
If we have mapped-key available (I mean, one already built dictionary that maps the US-Layout to XX-Layout), then we need to know how get the current layout, GLFW itself doesn't have anything. We need to call specific APIs from Windows/Linux/Darwin, just for that. 🤦♂️
Some locations (like France) don't uses QWERTY layout. Anyway, the "W" key is replaced with "Z", for instance. So, where is the W of QWERTY is printed as Z on the keyboard.
Using
KeyW
will work, since it uses the physical position of the key.However... Some games hint what key must be pressed, like: "Press W to go up". If the user is using AZERTY it might be better to display "Press Z to go up".
There's any way to identify which keyboard layout is be used?