kou-yeung / WebGLInput

IME for Unity WebGL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When focusing on the input field, Input.GetKeyDown cannot detect the event.

zaichenhu opened this issue · comments

Bug reproduction steps: Keep the input field focused (cursor blinking) and check for Input.GetKeyDown events (non-letter events, such as arrow keys) in the update function. You will find that the events are not triggered; in fact, no key events are triggered at all.

And this bug has been mentioned before. #40 you'll find that Input.anyKeyDown always be false.

because this plugins is need the keyboard event.
so, when you focus at input field. this plugins will set WebGLInput.captureAllKeyboardInput = false;
F.Y.R : https://docs.unity3d.com/ja/2022.3/ScriptReference/WebGLInput-captureAllKeyboardInput.html

if you want to save the string when the text updated.
you can subscribe the InputField.onValueChanged

or what are your use case. when you need the key event at editing the text?

or what are your use case. when you need the key event at editing the text?

My example is like this: I've implemented the "@" feature, just like most chat software does. When typing "@", a UI list containing names pops up. Then, I can use the arrow keys to select a name, while keeping the input box focused.
Here is where the need arises: when focusing on the input box, I need to use the keyboard to control other UI elements.

o.i see..
i think WebGLInput plugins can post the key event when inputfield recv the key event from javascript
keydown_event

but i don't know it can fulfill what you want to do or not

e.g. Implementation image

void Start()
{
    WebGLSupport.WebGLInput.KeyEvent += OnKeyEvent;
}

void OnKeyEvent(WebGLInput target, int keyCode)
{
    // ... you can check keycode here.
}

release a new version to add callback to listen keyboard event.
https://github.com/kou-yeung/WebGLInput/releases/tag/1.3.9

release a new version to add callback to listen keyboard event. https://github.com/kou-yeung/WebGLInput/releases/tag/1.3.9

The new release works well, thank you so much