Is there a way to keep the focus in the same text input after pressing enter?
I have a few form items in a dialog and when press the enter key the focus moves into another form item.
Actually they are not in a form.
Is there a way to keep the focus in the same text input after pressing enter?
I have a few form items in a dialog and when press the enter key the focus moves into another form item.
Actually they are not in a form.
Never mind I got it. In my change handler I added a call to focus():
myInput.addEventListener("change", myInputHandler);
myInput.addEventListener("input", myInputHandler);
myInputHandler(e) {
// do something
if (e.type=="change") {
myInput.focus(); // return focus
}
}
Thanks for posting the answer @Velara!