Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Digital Logic Sim

​A minimalistic digital logic simulator · By Sebastian Lague

Using arrow keys in text inputs gives invalid character [BUG]

A topic by Omay created Apr 12, 2025 Views: 306 Replies: 8
Viewing posts 1 to 9
(+1)

It does correctly move the cursor, however it also types the broken character.

I also experience this on Mac with apple silicon.

I’m also on Mac Apple Silicon

Developer(+1)

Could you please let me know if this still happens in version 2.0.4? I added a fix but don’t have a mac device to test right now

(+1)

I’ve tested the latest version, and it appears to not have been fixed. I can attempt trying to fix it, although I’m not too experienced with Unity.

Developer

Okay thanks for letting me know. If you want to attempt fixing, the relevant function is called InputField in the UI class. Specifically this code:

foreach (char c in InputHelper.InputStringThisFrame)
{
    bool invalidChar = char.IsControl(c) || char.IsSurrogate(c) || char.GetUnicodeCategory(c) == System.Globalization.UnicodeCategory.Format;
    if (invalidChar) continue;
    state.TryInsertText(c + "", validation);
}
(+1)

Alright, I got it fixed! Opened a PR in GitHub, and it works fine for me. Would be good if other people tried it, made sure it didn’t mess anything up.

(+1)

Congratulations for solving the problem in 3 hours, maybe it's rather simple (I know nothing about Unity but this is fast for me).

Once I got into the project, it took less than 10 minutes. It was a single line of code I had to modify. I just added logging to find out how to filter it out, and then did that. I used Unity for a very short period years ago, but I seem to have remembered most of the basic functionality, which made it easier.