add note about compareKeys - fixes #2400

This commit is contained in:
Becky Gilbert 2022-10-06 15:16:21 -07:00
parent f3c2895bde
commit fc78351ac1

View File

@ -21,7 +21,7 @@ var trial = {
target_direction: 'left'
},
on_finish: function(data){
// Score the response as correct or incorrect.
// Score the keyboard response as correct or incorrect.
if(jsPsych.pluginAPI.compareKeys(data.response, "f")){
data.correct = true;
} else {
@ -50,6 +50,20 @@ timeline.push(trial, feedback);
```
!!! note
When scoring a participant's response, the `jsPsych.pluginAPI.compareKeys` function is only needed to compare _keyboard_ responses. For other kinds of response types, such as button presses, you can compare the participant's response and correct response values directly, e.g.
```js
if (data.response == 0)){
data.correct = true;
} else {
data.correct = false;
}
```
Or:
```js
data.correct = data.response === data.correct_response;
```
### Randomizing a parameter value
Here's an example of using a dynamic parameter to randomize the inter-trial interval (ITI) duration. This time, the dynamic parameter is created using a named function instead of an anonymous function.