jsPsych not registering keypress in Qualtrics #3347
-
I am trying to run jsPsych inside a Qualtrics survey, a survey building GUI which allows JavaScript to be placed inside their questions. When doing so I can't seem to move past the first page by pressing any button, as prompted, despite this prompt being generated within jsPsych itself. Here's a minimal example that can be used inside the HTML section of a Qualtrics text/graphic question:
This can be adapted to be run directly in-browser by deleting the two lines referencing the NextButton. I've posted this in a single HTML file for brevity but I do usually use the recommended Qualtrics places for content in each of these tags: • Put into Look and Feel Although this doesn't change anything. I have also tried loading scripts inside the Qualtrics JavaScript editor:
Nothing has worked so far. I can see a keydown event listener is registered, although perhaps not fully or successfully. I am aware Qualtrics use a JavaScript Form Engine (basically is a Single Page Application), and perhaps this is interrupting the context in which the jsPsych scripts are able to register event listeners? Any help much appreciated! Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 10 replies
-
@Max-Lovell, just double checking: if you click on the "Welcome...." text and then press the key, does it still not progress? |
Beta Was this translation helpful? Give feedback.
-
@Max-Lovell I'd be happy to have a look at this, if you want to share your study with me (bgilbert at mit . edu). |
Beta Was this translation helpful? Give feedback.
-
Hi @Max-Lovell, thanks for sharing this with me! I had a look, and apparently my Qualtrics account doesn't let me use custom JavaScript, which is too bad because I'd love to play around with hosting jsPsych studies on Qualtrics Based on the Qualtrics docs and what you've said, It does sound like you've set up everything correctly. The difference you found in handler scopes between running via Qualtrics and locally is interesting, and it might be relevant. Though it could also just be a difference in the way the custom JS is loaded but not relevant to the keyboard listener problem. I'm not sure. I'd be more convinced that it's a scope problem if nothing at all were happening in response to keydown/up events, but in fact you ARE getting a response, which is good! It's just that the events are only triggering the Sorry that I can't dig into this more myself - as I said, I can't modify the JS and am reaching a limit of what I can debug just via the developer tools. Let us know if you get anywhere! |
Beta Was this translation helpful? Give feedback.
-
I'd be open to a PR that replaces |
Beta Was this translation helpful? Give feedback.
Hi @becky-gilbert,
You were right in that it wasn't arrow functions and involved this.listeners, which put me on the right path. The source of the issue is quite an annoying one - Qualtrics seem to have overridden the Array.from function .....(??!)
I have replaced the relevant instance of Array.from with the spread syntax
[…this.listeners]
, which is equivalent when using a simple array, and would only cause an issue in the event of Array.from being used on an object.You can see this change here. I have published a distribution of this from a separate branch and my jsPsych example script sources from this distribution in the header. Which can bee run locally and in Qualtrics without issue.
…