Return on focused text input

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