Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zaichenhu opened this issue May 24, 2024 · 6 comments
Closed

Comments

@zaichenhu
Copy link

zaichenhu commented May 24, 2024

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.

@kou-yeung kou-yeung added verification scheduled 検証予定 and removed verification scheduled 検証予定 labels May 24, 2024
@kou-yeung
Copy link
Owner

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

@kou-yeung
Copy link
Owner

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

@zaichenhu
Copy link
Author

zaichenhu commented May 24, 2024

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.

@kou-yeung
Copy link
Owner

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.
}

@kou-yeung
Copy link
Owner

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

@zaichenhu
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants