jsPsych/examples/case-sensitive-responses.html

49 lines
2.1 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<script src="../packages/jspsych/dist/index.browser.js"></script>
<script src="../packages/plugin-html-keyboard-response/dist/index.browser.js"></script>
<link rel="stylesheet" href="../packages/jspsych/css/jspsych.css">
</head>
<body></body>
<script>
var jsPsych = initJsPsych({
case_sensitive_responses: true, // to ignore the letter case of a keyboard response, set this parameter to false or remove it
on_finish: function() {
jsPsych.data.displayData();
}
});
var trial_1 = {
type: jsPsychHtmlKeyboardResponse,
stimulus: '<p>By default, jsPsych does not treat letter responses as case sensitive. So "A" (uppercase) is treated as "a" (lowercase).</p>'+
'<p>This is an example of an experiment where "case_sensitive_responses" is set to "true" in initJsPsych.</p>'+
'<p>To continue, you must press the letter "a" (lowercase).</p>'+
'<p>The trial will not end if you respond with "A" (uppercase), either by holding down the Shift key or turning CapsLock on.</p>',
choices: ['a']
};
var trial_2 = {
type: jsPsychHtmlKeyboardResponse,
stimulus: '<p>This is another example trial.</p>'+
'<p>To continue, now you must press the letter "A" (uppercase).</p>'+
'<p>The trial will not end if you respond with "a" (lowercase).</p>',
choices: ['A']
};
var trial_3 = {
type: jsPsychHtmlKeyboardResponse,
choices: "ALL_KEYS",
stimulus: '<p>When "case_sensitive_responses" is "true", your keyboard responses are case-sensitive in the data.</p>'+
'<p>The next page shows the data, with your response recorded as "a" for the first trial and "A" for the second trial.</p>'+
'<p>If you change "case_sensitive_responses" to "false" in initJsPsych and reload this expeirment<br>'+
'you will find that both "a" or "A" responses are valid responses for the first two trials,<br>'+
'and your response will always be recorded as "a" (lowercase) in the data.</p>'
};
jsPsych.run([trial_1, trial_2, trial_3]);
</script>
</html>