Typing I in my inventory search bar closes inventory window

My inventory window have a search bar for items, and it opens/closes by pressing “I”
The issue is that if I type, for instance, Liquid in my search bar, the I after the L and after the U will both open/close my inventory window, not to mention moving my character

My input is currently being handled by Input.GetKey and similar. What alternative can I use to avoid the input collision?

You put it on another key or you don’t close the inventory window while the search bar is in focus, something like this: https://docs.unity3d.com/ScriptReference/UI.InputField-isFocused.html

1 Like

Well, this is a terrible solution, but a solution nonetheless
Gonna have to add a ton of scripts checking all input fields every cycle for this to work.
Would be nice if input fields themselves would have a “currentFocusedInput” which I could check for null or something

Why?

And one single currentFocusedInput would be a really terrible solution, because you only want to limit the keystroke for one key, depending on the window is open and only for the inputs are in the current window. Unity does not have a way to know what key you’re using to open a window, that you have opened a window and you want to limit the keypress. This is how you can tell it: put the focused check regarding this specific input in the Input.GetKey if where you’re looking for closing the window.

What I wanted is a static variable in InputField class that can tell me if ANY input field has focus
You wouldn’t want your character walking and jumping regardless of which InputField is focused

Such variable could be set when you focus/unfocus the InputField, but that would require making my own InputField.
Right now I have to check every cycle for every InputField to see if it’s focused state changed

I think every tutorial tell us to disable movement scripts as soon as we open up any UI… It’s not input-related.

Edit: you don’t have to create your own input widget, just read the manual of the existing one. They have events when you enter or exit input so you can attach events to these.