What is the recommended way to block keyboard input as long as a UI input field is focused?
For example if I would like to block WASD movement in a game as soon as long as the chat is open.
The most obvious solution would be to disable/switch the Actionmap but that would not block input from public InputAction fields in MonoBehaviours and it would also block Gamepad input.
The optimal solution would be to lock keyboard input to the textinput field and block it from executing actions.
Is this possible?
Thanks,
Pascal
This should be handled by the UI input module internally and automatically. Added an internal ticket for this (ISX-340) and will get this looked at.
The by far simplest way ATM to silence keyboard input is to just disable the keyboard device outright.
InputSystem.DisableDevice(Keyboard.current);
// To re-enable.
InputSystem.EnableDevice(Keyboard.current);
Great this is exactly what I was looking for (I hope it still registers text input when disabled)
Was looking for sth like “Keyboard.current.SetActive”. Seems I was looking at the wrong class…
Regarding the input module: I am still using the default UI input module and besides the Input field is selected via script.
So I guess it might work with the new Input System Input Module.
I will have a try at this.
Thanks,
Pascal
Yup, it will.
ATM we have the unfortunate situation that text input in uGUI other than through IME is actually not going through the UI input module at all but rather picked up directly from the native Unity runtime. We’re working with the UI team to resolve this and to give the input module a means of knowing when the UI is consuming text input.
hello, there.
how’s this topic goin’ ?
1 Like
Please don’t necro posts for such a pointless reason.
2 Likes
Do you know how this is done in the old input system?