'Enter','ArrowRight','ArrowLeft' as Invalid key string #1559
-
Hi there, I'm using jspsych-6.2.0 and I specified the following plugin for example as below:
Nothing happened when I did then press the right arrow while seeing YY, that is, the next screen is not displayed. There is no error message. I tried chrome and internet explorer and both lead to the same issue. If instead I replace 'ArrowRight' by 'f', then pressing 'f' works (in that I move to the next screen). Pressing the right arrow e.g. on https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/ does return the relevant code. Any idea of what could be wrong? Thanks for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Converting this to a discussion. |
Beta Was this translation helpful? Give feedback.
-
Hi @BastienBlain! Try this: var XX = {
type: "html-keyboard-response",
stimulus: "YY",
choices: ['rightarrow']
}; Long answer: I think you're running into two different problems here.
|
Beta Was this translation helpful? Give feedback.
Hi @BastienBlain! Try this:
Long answer: I think you're running into two different problems here.
choices
parameter must be an array, e.g.choices: ['f']
. If you use a string, then jsPsych will treat the string as an array, which means that every character in the string will become a separate valid key choice. This means that usingchoices: 'f'
(without the square brackets) will actually work as expected, even though 'f' isn't inside an array. But if you usechoices: 'ArrowRight'
, this string will become an array: 'a','r','r','o'... etc. You can see this for yourself by usingchoices: 'ArrowRi…