simulate mouse click | XM Community
Solved

simulate mouse click

  • 8 January 2019
  • 3 replies
  • 34 views

Userlevel 1
Hi

I have coded that my text form item dynamically adjusts when I mouse-click into the last form field (adds a new text entry box for an additional entry). It works fine but because it uses questionclick only if you use your mouse and obviously not if you use the tab key to move from one text box entry to the next. I didnt find an API that adds a listener for a tab event. Is there any way to simulate entering the tab key as a mouse-click?

Thanks in advance!
icon

Best answer by TomG 8 January 2019, 20:50

View original

3 replies

Userlevel 7
Badge +27
You could use focus events on the input boxes instead of questionclick. A focus event would fire when a text field is clicked on or tabbed to.
Userlevel 1
Thanks! This isn't included in Qualtrics JS Question API though, right? How can I make use of the focus function, do I need an event listener first?
Userlevel 7
Badge +27
> @automaticadd said:
> Thanks! This isn't included in Qualtrics JS Question API though, right? How can I make use of the focus function, do I need an event listener first?

Focus is a JS event. You can use the jQuery focus() function to bind an event handler to the text input fields, something like:
```
jQuery("#"+this.questionId+" .InputText").focus(function() {
//your code goes here
});
```

Leave a Reply