Removing focus from text entry field by hitting enter

Feb 03, 2022

It's possible I've re-invented the wheel here, but I wasn't able to find the answer on google and it took me a while to figure out, so I thought I'd share my solution.

The issue

We needed to build a simplified mock-up of an online widget. The user can add text, and - when they click enter - the text should be saved - there is no save button or equivalent. We needed a way for the text entry field to lose focus from hitting enter on the keyboard.

Solution

Add a new layer with a different text-entry field (off screen), which takes the focus off the main box, have the new layer close down straight away. (example attached).

2 Replies