`getKeyboardResponse` can return a lower case version of the `key` in some circumstances
The description of the parameter choices in html-keyboard-response in jsPsych v7 seems to be incorrect.
jsPsych v7 plugin page of html-keyboard-response
Enter key was detected with 'enter', not 'Enter'. The down arrow key was detected with 'arrowdown', not 'ArrowDown'. The version of jsPsych used for testing was V7.3.4.
At least as of 2024/06/21, the reference link attached in the table was not informative.
Please correct the description of the plugin page and provide a list of correct key names that jsPsych can accept. Thank you in advance.
Hi @TAOKA-Daiki,
I just double checked this and, at least in Chromium, the event.key property is Enter for the enter key and ArrowDown for the arrow down key. What browser did you test this on?
Thank you for early reply and checking, @jodeleeuw.
My jsPsych v7 program runs on the Google Chrome version 126.0.6478.61 (64 bit for Windows). I have just tried updating Chrome to the latest version (126.0.6478.115) and tested my program again, but the issue persisted. The same was true on Microsoft Edge version 126.0.2592.68.
Can you clarify what the issue is?
The key strings are not case sensitive, so if you are using "enter" that will work just as well as "Enter". When the event is generated by the browser it uses the capitalization that is shown in the documentation. Are you seeing a case where "Enter" does not work but "enter" does?
I have checked the source code of jsPsych.js and understood the reason for the issue.
As you said, the areResponsesCaseSensitive property of the KeyboardListerAPI in jsPsych v7 is false by default (in line 681 of jsPsych.js). And in the getKeyboardResponse method, the list of key names given to valid_responses is converted to lowercase (in line 741 of jsPsych.js).
I am currently working on tweaking my custom plugin (modified from plugin-html-keyboard-response.js). My custom plugin accepts numeric and Backspace keys and displays the input value on screen, and then participant determines the input by pressing the Enter key.
What I have stuck this time is the after_response = (info) => {} function in the custom plugin. As I mentioned above, inside jsPsych v7, key names are converted to lowercase. Therefore, in the after_response function, the key cannot be detected correctly unless info.key == 'enter' instead of info.key == 'Enter'. On the other hand, in the info.choices property of trial, both 'Enter' and 'enter' are valid. I could not understand this behavior and mistakenly thought that all key names had to be specified in lowercase.
Understanding the internal processing of jsPsych helped me understand the reason for the problem. The content of the plugin page is not completely incorrect. But in any case, it seems to me that this behavior is likely to be misleading (especially in a case like mine).
Thanks for clarifying!
I think we should consider outputting the standard Enter instead of enter for the info.key. @jspsych/core any concerns?
This will be fixed in v8.0