Getting inputs from non-English keyboard layouts

I’m specifically interested in Czech keyboard layout. Instead having numbers in the top row, we use it to house out many characters with diacritics: ě, š, č, ř and so forth. Right now the results of pressing those keys are not very useful and also inconsistent:

Holding keys “š”, “ž”, “ý” and the rest of the row only sends a text action with the correct letter. Keys “ě”, “č” and “ř” send one text action with the correct letter and then repeatedly normal action “key_e”, “key_c” or “key_r” respectively, so any action bound to these letters without diacritics would also happen when pressing the key with the accented version.

Since I won’t be needing to keep track of whether these particular keys are held and am only interested in the initial press, I think I can use the text action for most of these and come up with some ugly workaround to detect whether a text action “ě” was sent in the same frame as the “e” key was pressed, but I’d rather find a better solution, also because of future projects.

1 Like

Huh. I was getting ready to implement the workaround I mentioned and for some reason all the special characters only send a text action now, including “ě”, “č” and “ř”. This is good news, as I can simply use text actions and there should be no issues, but I’m a little bit worried because I can’t figure out what I did differently.

This is on the same computer, without updating Defold, using (I think) the same on_input function as yesterday. Did anything change on build server side? If it works, it works, but I’d hate for it to pop up again.

Nope, nothing has changed. I can’t explain why it behaved like it did. Black magic or voodoo?!

Spooky! Well, I’ll pretend it never happened and be on a lookout for issues.

I definitely didn’t dream it, though - I actually first ran into this issue when playing Fates of Ort - binding the “ě” key mapped the action to “e” too. I haven’t mentioned it though, since these kinds of issues are really quite common, sometimes even in AAA games, and it’s easily fixed on my end by switching to the English layout with a keyboard shortcut - something all Czech gamers have long since learnt to do.

However, since my current project is currently aimed at Czech audience as well as people who don’t play computer games regularly, I want to be extra safe when it comes to things like this.

I’ll report back if I find out anything new.

2 Likes

This is honestly one of my big pet peeves with Defold and one of the reasons I use Love2D for my desktop projects. Since you don’t have access to the scancodes, no one with a non-American keyboard layout can play your game without mucking around with their OS settings.

1 Like

We agree, and that’s why we added the raw input for gamepads, and we want the same for keyboards.

3 Likes