mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
added keys option to XAB
Added two optional parameters to the XAB plugin so that they key that subjects press to answer left/right is a parameter. The parameters have default values of 'q' and 'p' to maintain compatibility.
This commit is contained in:
parent
39846f1754
commit
b8a72862cf
@ -16,9 +16,9 @@
|
|||||||
trials[i]["a_path"] = xab_stims[i][0];
|
trials[i]["a_path"] = xab_stims[i][0];
|
||||||
trials[i]["b_path"] = xab_stims[i][1];
|
trials[i]["b_path"] = xab_stims[i][1];
|
||||||
trials[i]["timing"] = params["timing"];
|
trials[i]["timing"] = params["timing"];
|
||||||
if(params["data"]!=undefined){
|
trials[i]["data"] = params["data"][i] || params["data"] || undefined;
|
||||||
trials[i]["data"] = params["data"][i];
|
trials[i]["left_key"] = params["left_key"] || 81; // defaults to 'q'
|
||||||
}
|
trials[i]["right_key"] = params["right_key"] || 80; // defaults to 'p'
|
||||||
}
|
}
|
||||||
return trials;
|
return trials;
|
||||||
}
|
}
|
||||||
@ -62,11 +62,11 @@
|
|||||||
var resp_func = function(e) {
|
var resp_func = function(e) {
|
||||||
var flag = false;
|
var flag = false;
|
||||||
var correct = false;
|
var correct = false;
|
||||||
if(e.which=='80') // 'p' key
|
if(e.which== trial.left_key) // 'p' key
|
||||||
{
|
{
|
||||||
flag = true;
|
flag = true;
|
||||||
if(!target_left) { correct = true; }
|
if(!target_left) { correct = true; }
|
||||||
} else if(e.which=='81') // 'q' key
|
} else if(e.which== trial.right_key) // 'q' key
|
||||||
{
|
{
|
||||||
flag = true;
|
flag = true;
|
||||||
if(target_left){ correct = true; }
|
if(target_left){ correct = true; }
|
||||||
|
Loading…
Reference in New Issue
Block a user