ebiten
ebiten copied to clipboard
Proposal: add GetLocalizedKeyName function
Suppose that I want to make the game display the message "Press "W" to walk forward". However if the person playing the game has the French layout, I'd like to show "Press "Z" to walk forward" instead (because in AZERTY "Z" is in the same position as "W" on QWERTY)
glfw has glfwGetKeyName function to obtain the name of the key, it looks like we can use it for obtaining this mapping for some platforms.
The interface can be as follows for Ebiten:
func GetLocalizedKeyName(key Key) string { ... }
And finally, the end users will be able to do this:
DisplayMessage(fmt.Sprintf("Press %q to walk forward", ebiten.GetLocalizedKeyName(ebiten.KeyW)))
@wasedaigo might want this?
https://github.com/go-gl/glfw/blob/a6c407ee30a0/v3.3/glfw/input.go#L444
This would work. Unfortunately I need to (re)implement this for Windows (internal/glfwwin)
Unfortunately there seems no easy portable way to implement this. For example, on browsers, key
is a little different thing from glfw.GetKeyName
.
Let me change the milestone.
Hm, how can I implement this for browsers?
EDIT: https://developer.mozilla.org/en-US/docs/Web/API/Keyboard/getLayoutMap
I've implemented KeyName
for desktops and browsers.
For mobiles, I'll create a separate issue.
For consoles, I don't implement this (keyboards are not supported).