InputField Focus Triggers OnEndEdit and TouchScreenKeyboard.Done triggers on loss of focus- What now

My issue is pretty simple- I don’t want to accept user input unless they’ve hit Done/Enter on their mobile device keyboard. This has becomes really difficult in a way that makes me feel like I’m overlooking something. Here’s the issue:

  • If a user clicks away from the input field and it loses focus, the field “submits” their input. I don’t want this to happen.
  • So I figured I’d listen and if they hit Enter, I’d flip a flag and check the input. However, there’s no keycode for mobile keyboard Enter/Done buttons
  • Instead, there’s a .Done() function in TouchScreenKeyboard class. However, .Done() also seems to trigger when the field is unfocused, recreating the problem I had in the first place.

Is there a solve here?

I was also struggling with this problem, but couldn’t find any way to solve it. Another problem is that Unity’s EventSystem can’t register any touch/click outside of the keyboard while the keyboard is activated…

A lot of threads are adressing this problem with no answer at all.

There is also an open issue: Unity Issue Tracker - When pressing outside the touchscreen keyboard on Android devices, wasCanceled state is false

I think this problem can only be solved within the TouchScreenKeyboard class. So any information from the Unity-team would be really helpful.

1 Like