mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
add note about compareKeys - fixes #2400
This commit is contained in:
parent
f3c2895bde
commit
fc78351ac1
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user