Return on focused text input

There’s a text input I have and I want it so when people write on it and press enter something happens, but while this works


It also requires the user to click somewhere else, to unfocus the text input so it’s saved or something, can I make it so it doesn’t require that extra click?

1 Like

I still couldn’t do this

1 Like

You want to focus or unfocus? Ok unfocus, I will try that with javascript

Unfortunately this isn’t possible. Here’s a thread about it:

Edit: this is about how you can’t just press Enter (for example) to commit the text of an input field.

1 Like

thats very simple:

runtimeScene.getObjects("Name")[0]._renderer.input.blur()

but as @worriedpixels stated, you still cant check keypresses

1 Like

But since I love javascript, I got this code that checks if the enter key is pressed even while focusing the text input, then unfocus it.

if (objects.length > 0) {
    const renderer = objects[0]._renderer;

    document.onkeypress = function(e) {
        e = e || window.event;
        const key = e.keyCode;
        if (key === 13) {
            renderer._input.blur();
        }
    }
}
1 Like