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

OK, got the bug working again. Seems the spooky part was that it only happens on my computer at home, not on the one I use at work. I could have sworn I originally tested it at work, but I probably just misremembered.

Both PCs are running windows 10, though the work computer (where “ě” only sends a text action) has Czech set as the system language, while I’m using English (UK) at home (and it sends both “ě” as a text action and “e” as normal key press at the same time).

I’ve tried fiddling with the way my keyboard is set up at home. Originally it was displayed as English (Czech), which makes no sense to me, but it worked. For writing, I mean. I tried installing Czech (Czech) keyboard, but saw no change in my game’s behaviour. I suppose I could try switching the system language to Czech altogether, but then again I might just implement the workaround I mentioned earlier and pretend this never happened. The way languages and keyboards are handled in windows (and actually on android too) gives me a headache.

Added https://github.com/defold/defold/issues/6080

1 Like

Same problem with french keyboards.
Numbers of the upper row are available only with combination of shift key.

Even if i put my keyboard to a QWERTY layout , it doesn’t work.
That’s odd, i was expecting it working with QWERTY layout (as obviously, it’s the keycode which is read, and not the scancode.)

Attached is a small project for testing. It works on physical QWERTY keyboards, and not on AZERTY.

test_clavier.zip (4.4 KB)