HTML5 & Windows - Inconsistent 'Enter Key'

I posted a report on this bug here on GitHub, but I’m also posting here in case I’m missing something, or if a workaround is possible.

On Windows, pressing the enter key returns itself as a key value, as designated in the game input_bindings in my project. On HTML5, however, it returns itself as a text value and then a key value.

I’m not sure if it’s normal to have the enter key bound to a text value, even more so a tilde (~) on HTML5, but that’s what it returns when passed as a text value. An interesting property it has, is that it’s like a “ghost tilde”. I tested this by comparing a “shift” + “~” combo to the action.text of the enter key. It returned false, as in it wasn’t the same. I even printed the values. They were the same, but not the same?

Anyway, this is game breaking if I wish to make an HTML5 version, because my game relies heavily on commands and text input. One example is the ‘fire #OfShots’ command. If you concatenate a tilde on the end, it turns the number into a string. No ammo for you!!!

EDIT: I forgot to explain the steps:

  1. Input is received. If it is a text value, the command line accepts the input and concatenates each character input.

  2. If it is the enter key, the text that has built up from multiple inputs is sent as one whole message and printed. It’s also processed for linebreaking and command-checking.

Has anyone run into this issue and solved it? I’ve tried multiple theories, but they failed.

Are you sure that you get tilde back? The font rendering in Defold substitutes glyphs that are not part of the font with tildes so if you use a GUI text node to view the result, that may be what happens.

I was sure until now :sweat_smile: . I am trying to test this by turning “special characters” on in the system font, but your RenderCam library, or the engine, has decided NOW OF ALL TIMES was the perfect time to report a “response code: 400 for URL” message when building for HTML. I think it’s telling me to go to bed. I’ll have to check it in the morning.

@sicher I would recommend though, if any key is missing from the font and returns a “mock” tilde key, it should really just return a true tilde key. That way this doesn’t happen again, and it makes life a little easier to deal with. I still have no way of dealing with this besides finding a new font which supports the enter key’s text value (which I have absolutely no way of knowing what that is) or skipping the HTML5 bundle. It’s quite a hassle for this one little thing. I’m a special case though, so I understand if you decide not to because this requires work and will have little benefit to you guys.

1 Like

The font system does not return anything, it just renders on screen. So if you type “ø” in a gui text node and your font is missing a glyph for that character, a tilde is rendered. If you want to inspect returned character codes, it’s better to print the values to the console or inspect with the debugger:

print(string.byte("A")) --> 65
2 Likes