A
A
Alexander Dyupachev2020-05-08 21:09:10
Unity
Alexander Dyupachev, 2020-05-08 21:09:10

How to track UP and DOWN key presses in a TextInput field (Text Mesh Pro)?

I'm writing a simple console emulator and I'm having trouble tracking the UP and DOWN keys pressed in a text field. Can anyone come across and know how to intercept this event? Tried through OnValueChange, but this event only fires when printing or deleting a character.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2020-05-09
@inetti

The TextInput class does not have such an event, there is no way through it.
You can start a coroutine when this text field is clicked, and stop it in the EndEdit event.
And in the coroutine, through the Input class, check the pressing of these keys. Input.GetKeyDown(KeyCode.UpArrow)
To fire on click, implement the IPointerClickHandler interface.
You can see the full list of UI events here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question