Skip to main content
15-Moonstone
June 22, 2022
Question

keypress event on textinput

  • June 22, 2022
  • 1 reply
  • 1133 views

Hello I want to find a way to implement the following keypress method on text input widget in vuforia studio.

 

var input = document.getElementById("textInput-1");
input.addEventListener("keypress", function(event) {
 if (event.key === "Enter") {
 event.preventDefault();
 document.getElementById("button-5").click();
 }
});

 

 

 

1 reply

21-Topaz I
June 23, 2022

I think we need to pay attention that event should work also on mobile device - and not only inside chrome

So the Input box have click and value change. So you could every time perform a check  when the event "value change" of the input widget  is fired and then you could try compare the new value of the input widget text with the old (so need to saved after every change the value e.g. to js global variable or to app parameter) the difference will be the added character.

Here some list of events in Studio

GianVal15-MoonstoneAuthor
15-Moonstone
June 23, 2022

Thank you for your reply. Basically, I want to press the enter button of the keyboard to perform a "virtual" click of a search button beside a text input area.