mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
fix more instances of jsPsych.NO/ALL_KEYS
This commit is contained in:
parent
f875ecc84c
commit
d6d3b75326
@ -135,7 +135,7 @@
|
|||||||
var trial = {
|
var trial = {
|
||||||
type: jsPsychImageKeyboardResponse,
|
type: jsPsychImageKeyboardResponse,
|
||||||
stimulus: 'img/blue.png',
|
stimulus: 'img/blue.png',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: 2000,
|
trial_duration: 2000,
|
||||||
extensions: [
|
extensions: [
|
||||||
{
|
{
|
||||||
@ -153,7 +153,7 @@
|
|||||||
return `<p style="margin-bottom:0px;"><strong>Trial data:</strong></p>
|
return `<p style="margin-bottom:0px;"><strong>Trial data:</strong></p>
|
||||||
<pre style="margin-top:0px;text-align:left;">${trial_json}</pre>`;
|
<pre style="margin-top:0px;text-align:left;">${trial_json}</pre>`;
|
||||||
},
|
},
|
||||||
choices: jsPsych.NO_KEYS
|
choices: "NO_KEYS"
|
||||||
};
|
};
|
||||||
|
|
||||||
jsPsych.run([
|
jsPsych.run([
|
||||||
|
@ -301,7 +301,7 @@ If you have tips based on your own experience please consider sharing them on ou
|
|||||||
var trial = {
|
var trial = {
|
||||||
type: jsPsychImageKeyboardResponse,
|
type: jsPsychImageKeyboardResponse,
|
||||||
stimulus: 'img/blue.png',
|
stimulus: 'img/blue.png',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: 2000,
|
trial_duration: 2000,
|
||||||
extensions: [
|
extensions: [
|
||||||
{
|
{
|
||||||
@ -319,7 +319,7 @@ If you have tips based on your own experience please consider sharing them on ou
|
|||||||
return `<p style="margin-bottom:0px;"><strong>Trial data:</strong></p>
|
return `<p style="margin-bottom:0px;"><strong>Trial data:</strong></p>
|
||||||
<pre style="margin-top:0px;text-align:left;">${trial_json}</pre>`;
|
<pre style="margin-top:0px;text-align:left;">${trial_json}</pre>`;
|
||||||
},
|
},
|
||||||
choices: jsPsych.NO_KEYS
|
choices: "NO_KEYS"
|
||||||
};
|
};
|
||||||
|
|
||||||
jsPsych.run([
|
jsPsych.run([
|
||||||
|
@ -313,7 +313,7 @@ var save_data = {
|
|||||||
var fail_message = {
|
var fail_message = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: 'The experiment failed to load. Please contact the researcher.',
|
stimulus: 'The experiment failed to load. Please contact the researcher.',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: null
|
trial_duration: null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ If you want CSS rules that only apply to specific elements during a trial, you c
|
|||||||
<script>
|
<script>
|
||||||
var fixation_trial = {
|
var fixation_trial = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
stimulus: '+',
|
stimulus: '+',
|
||||||
css_classes: ['fixation']
|
css_classes: ['fixation']
|
||||||
};
|
};
|
||||||
|
@ -49,14 +49,14 @@ You can accomplish this in a couple different ways.
|
|||||||
|
|
||||||
One option is to create a trial that contains a link that the participant clicks to end the experiment and return to Prolific. For example, the `html-keyboard-response` plugin can be used to display text that includes a link. This could go on a debriefing page.
|
One option is to create a trial that contains a link that the participant clicks to end the experiment and return to Prolific. For example, the `html-keyboard-response` plugin can be used to display text that includes a link. This could go on a debriefing page.
|
||||||
|
|
||||||
Here's an example trial that could be used. Note that `choices` is set to `jsPsych.NO_KEYS`, which will prevent the participant from continuing past this point in the experiment.
|
Here's an example trial that could be used. Note that `choices` is set to `"NO_KEYS"`, which will prevent the participant from continuing past this point in the experiment.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var final_trial = {
|
var final_trial = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: `<p>You've finished the last task. Thanks for participating!</p>
|
stimulus: `<p>You've finished the last task. Thanks for participating!</p>
|
||||||
<p><a href="https://app.prolific.co/submissions/complete?cc=XXXXXXX">Click here to return to Prolific and complete the study</a>.</p>`,
|
<p><a href="https://app.prolific.co/submissions/complete?cc=XXXXXXX">Click here to return to Prolific and complete the study</a>.</p>`,
|
||||||
choices: jsPsych.NO_KEYS
|
choices: "NO_KEYS"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ You can use a static `css_classes` parameter value if you always want to apply t
|
|||||||
var fixation = {
|
var fixation = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '+',
|
stimulus: '+',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: 500,
|
trial_duration: 500,
|
||||||
css_classes: ['fixation']
|
css_classes: ['fixation']
|
||||||
}
|
}
|
||||||
|
@ -107,13 +107,13 @@ var face_name_procedure = {
|
|||||||
{
|
{
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '+',
|
stimulus: '+',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: 500
|
trial_duration: 500
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: jsPsychImageKeyboardResponse,
|
type: jsPsychImageKeyboardResponse,
|
||||||
stimulus: jsPsych.timelineVariable('face'),
|
stimulus: jsPsych.timelineVariable('face'),
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: 2500
|
trial_duration: 2500
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -136,19 +136,19 @@ var face_name_procedure = {
|
|||||||
{
|
{
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '+',
|
stimulus: '+',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: 500
|
trial_duration: 500
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: jsPsych.timelineVariable('name'),
|
stimulus: jsPsych.timelineVariable('name'),
|
||||||
trial_duration: 1000,
|
trial_duration: 1000,
|
||||||
choices: jsPsych.NO_KEYS
|
choices: "NO_KEYS"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: jsPsychImageKeyboardResponse,
|
type: jsPsychImageKeyboardResponse,
|
||||||
stimulus: jsPsych.timelineVariable('face'),
|
stimulus: jsPsych.timelineVariable('face'),
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: 1000
|
trial_duration: 1000
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -173,14 +173,14 @@ var face_name_procedure = {
|
|||||||
{
|
{
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '+',
|
stimulus: '+',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: 500
|
trial_duration: 500
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: jsPsych.timelineVariable('name'),
|
stimulus: jsPsych.timelineVariable('name'),
|
||||||
trial_duration: 1000,
|
trial_duration: 1000,
|
||||||
choices: jsPsych.NO_KEYS
|
choices: "NO_KEYS"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
@ -190,7 +190,7 @@ var face_name_procedure = {
|
|||||||
<p>${jsPsych.timelineVariable('name')}</p>`;
|
<p>${jsPsych.timelineVariable('name')}</p>`;
|
||||||
return html;
|
return html;
|
||||||
},
|
},
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: 2500
|
trial_duration: 2500
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -12,7 +12,7 @@ stimuli | array | *undefined* | Each element of the array is a path to an image
|
|||||||
frame_time | numeric | 250 | How long to display each image (in milliseconds).
|
frame_time | numeric | 250 | How long to display each image (in milliseconds).
|
||||||
frame_isi | numeric | 0 | If greater than 0, then a gap will be shown between each image in the sequence. This parameter specifies the length of the gap.
|
frame_isi | numeric | 0 | If greater than 0, then a gap will be shown between each image in the sequence. This parameter specifies the length of the gap.
|
||||||
sequence_reps | numeric | 1 | How many times to show the entire sequence. There will be no gap (other than the gap specified by `frame_isi`) between repetitions.
|
sequence_reps | numeric | 1 | How many times to show the entire sequence. There will be no gap (other than the gap specified by `frame_isi`) between repetitions.
|
||||||
choices | array of strings | `jsPsych.ALL_KEYS` | This array contains the key(s) that the subject is allowed to press in order to respond to the stimulus. Keys should be specified as characters (e.g., `'a'`, `'q'`, `' '`, `'Enter'`, `'ArrowDown'`) - see [this page](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) and [this page (event.key column)](https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/) for more examples. Any key presses that are not listed in the array will be ignored. The default value of `jsPsych.ALL_KEYS` means that all keys will be accepted as valid responses. Specifying `jsPsych.NO_KEYS` will mean that no responses are allowed.
|
choices | array of strings | `"ALL_KEYS"` | This array contains the key(s) that the subject is allowed to press in order to respond to the stimulus. Keys should be specified as characters (e.g., `'a'`, `'q'`, `' '`, `'Enter'`, `'ArrowDown'`) - see [this page](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) and [this page (event.key column)](https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/) for more examples. Any key presses that are not listed in the array will be ignored. The default value of `"ALL_KEYS"` means that all keys will be accepted as valid responses. Specifying `"NO_KEYS"` will mean that no responses are allowed.
|
||||||
prompt | string | null | This string can contain HTML markup. Any content here will be displayed below the stimulus. The intention is that it can be used to provide a reminder about the action the subject is supposed to take (e.g., which key(s) to press).
|
prompt | string | null | This string can contain HTML markup. Any content here will be displayed below the stimulus. The intention is that it can be used to provide a reminder about the action the subject is supposed to take (e.g., which key(s) to press).
|
||||||
render_on_canvas | boolean | true | If true, the images will be drawn onto a canvas element. This prevents a blank screen (white flash) between consecutive images in some browsers, like Firefox and Edge. If false, the image will be shown via an img element, as in previous versions of jsPsych.
|
render_on_canvas | boolean | true | If true, the images will be drawn onto a canvas element. This prevents a blank screen (white flash) between consecutive images in some browsers, like Firefox and Edge. If false, the image will be shown via an img element, as in previous versions of jsPsych.
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ In addition to the [parameters available in all plugins](../overview/plugins.md#
|
|||||||
| Parameter | Type | Default Value | Description |
|
| Parameter | Type | Default Value | Description |
|
||||||
| ------------------------------ | ---------------- | ------------------ | ---------------------------------------- |
|
| ------------------------------ | ---------------- | ------------------ | ---------------------------------------- |
|
||||||
| stimuli | array | *undefined* | Each element of the array is a path to an image file. |
|
| stimuli | array | *undefined* | Each element of the array is a path to an image file. |
|
||||||
| choices | array of strings | `jsPsych.ALL_KEYS` | This array contains the key(s) that the subject is allowed to press in order to respond to the stimulus. Keys should be specified as characters (e.g., `'a'`, `'q'`, `' '`, `'Enter'`, `'ArrowDown'`) - see [this page](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) and [this page (event.key column)](https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/) for more examples. Any key presses that are not listed in the array will be ignored. The default value of `jsPsych.ALL_KEYS` means that all keys will be accepted as valid responses. Specifying `jsPsych.NO_KEYS` will mean that no responses are allowed. |
|
| choices | array of strings | `"ALL_KEYS"` | This array contains the key(s) that the subject is allowed to press in order to respond to the stimulus. Keys should be specified as characters (e.g., `'a'`, `'q'`, `' '`, `'Enter'`, `'ArrowDown'`) - see [this page](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) and [this page (event.key column)](https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/) for more examples. Any key presses that are not listed in the array will be ignored. The default value of `"ALL_KEYS"` means that all keys will be accepted as valid responses. Specifying `"NO_KEYS"` will mean that no responses are allowed. |
|
||||||
| key_answer | string | *undefined* | The key character indicating the correct response. |
|
| key_answer | string | *undefined* | The key character indicating the correct response. |
|
||||||
| text_answer | string | "" | A text label that describes the correct answer. Used in conjunction with the `correct_text` and `incorrect_text` parameters. |
|
| text_answer | string | "" | A text label that describes the correct answer. Used in conjunction with the `correct_text` and `incorrect_text` parameters. |
|
||||||
| correct_text | string | "Correct." | String to show when the correct answer is given. Can contain HTML formatting. The special string `%ANS%` can be used within the string. If present, the plugin will put the `text_answer` for the trial in place of the %ANS% string (see example below). |
|
| correct_text | string | "Correct." | String to show when the correct answer is given. Can contain HTML formatting. The special string `%ANS%` can be used within the string. If present, the plugin will put the `text_answer` for the trial in place of the %ANS% string (see example below). |
|
||||||
|
@ -9,7 +9,7 @@ In addition to the [parameters available in all plugins](../overview/plugins.md#
|
|||||||
| Parameter | Type | Default Value | Description |
|
| Parameter | Type | Default Value | Description |
|
||||||
| -------------------------- | ---------------- | ------------------------ | ---------------------------------------- |
|
| -------------------------- | ---------------- | ------------------------ | ---------------------------------------- |
|
||||||
| stimulus | html string | *undefined* | The HTML stimulus to display. |
|
| stimulus | html string | *undefined* | The HTML stimulus to display. |
|
||||||
| choices | array of strings | `jsPsych.ALL_KEYS` | This array contains the key(s) that the subject is allowed to press in order to respond to the stimulus. Keys should be specified as characters (e.g., `'a'`, `'q'`, `' '`, `'Enter'`, `'ArrowDown'`) - see [this page](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) and [this page (event.key column)](https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/) for more examples. Any key presses that are not listed in the array will be ignored. The default value of `jsPsych.ALL_KEYS` means that all keys will be accepted as valid responses. Specifying `jsPsych.NO_KEYS` will mean that no responses are allowed. |
|
| choices | array of strings | `"ALL_KEYS"` | This array contains the key(s) that the subject is allowed to press in order to respond to the stimulus. Keys should be specified as characters (e.g., `'a'`, `'q'`, `' '`, `'Enter'`, `'ArrowDown'`) - see [this page](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) and [this page (event.key column)](https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/) for more examples. Any key presses that are not listed in the array will be ignored. The default value of `"ALL_KEYS"` means that all keys will be accepted as valid responses. Specifying `"NO_KEYS"` will mean that no responses are allowed. |
|
||||||
| key_answer | string | *undefined* | The key character indicating the correct response. |
|
| key_answer | string | *undefined* | The key character indicating the correct response. |
|
||||||
| text_answer | string | "" | A label that is associated with the correct answer. Used in conjunction with the `correct_text` and `incorrect_text` parameters. |
|
| text_answer | string | "" | A label that is associated with the correct answer. Used in conjunction with the `correct_text` and `incorrect_text` parameters. |
|
||||||
| correct_text | string | "Correct." | String to show when the correct answer is given. Can contain HTML formatting. The special string `%ANS%` can be used within the string. If present, the plugin will put the `text_answer` for the trial in place of the `%ANS%` string (see example below). |
|
| correct_text | string | "Correct." | String to show when the correct answer is given. Can contain HTML formatting. The special string `%ANS%` can be used within the string. If present, the plugin will put the `text_answer` for the trial in place of the `%ANS%` string (see example below). |
|
||||||
|
@ -10,7 +10,7 @@ In addition to the [parameters available in all plugins](../overview/plugins.md#
|
|||||||
| -------------------------- | ---------------- | ------------------------ | ---------------------------------------- |
|
| -------------------------- | ---------------- | ------------------------ | ---------------------------------------- |
|
||||||
| stimulus | string | *undefined* | The path to the image file. |
|
| stimulus | string | *undefined* | The path to the image file. |
|
||||||
| key_answer | string | *undefined* | The key character indicating the correct response. |
|
| key_answer | string | *undefined* | The key character indicating the correct response. |
|
||||||
| choices | array of strings | `jsPsych.ALL_KEYS` | This array contains the key(s) that the subject is allowed to press in order to respond to the stimulus. Keys should be specified as characters (e.g., `'a'`, `'q'`, `' '`, `'Enter'`, `'ArrowDown'`) - see [this page](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) and [this page (event.key column)](https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/) for more examples. Any key presses that are not listed in the array will be ignored. The default value of `jsPsych.ALL_KEYS` means that all keys will be accepted as valid responses. Specifying `jsPsych.NO_KEYS` will mean that no responses are allowed. |
|
| choices | array of strings | `"ALL_KEYS"` | This array contains the key(s) that the subject is allowed to press in order to respond to the stimulus. Keys should be specified as characters (e.g., `'a'`, `'q'`, `' '`, `'Enter'`, `'ArrowDown'`) - see [this page](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) and [this page (event.key column)](https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/) for more examples. Any key presses that are not listed in the array will be ignored. The default value of `"ALL_KEYS"` means that all keys will be accepted as valid responses. Specifying `"NO_KEYS"` will mean that no responses are allowed. |
|
||||||
| text_answer | string | "" | A label that is associated with the correct answer. Used in conjunction with the `correct_text` and `incorrect_text` parameters. |
|
| text_answer | string | "" | A label that is associated with the correct answer. Used in conjunction with the `correct_text` and `incorrect_text` parameters. |
|
||||||
| correct_text | string | "Correct." | String to show when the correct answer is given. Can contain HTML formatting. The special string `%ANS%` can be used within the string. If present, the plugin will put the `text_answer` for the trial in place of the %ANS% string (see example below). |
|
| correct_text | string | "Correct." | String to show when the correct answer is given. Can contain HTML formatting. The special string `%ANS%` can be used within the string. If present, the plugin will put the `text_answer` for the trial in place of the %ANS% string (see example below). |
|
||||||
| incorrect_text | string | "Wrong." | String to show when the wrong answer is given. Can contain HTML formatting. The special string `%ANS%` can be used within the string. If present, the plugin will put the `text_answer` for the trial in place of the %ANS% string (see example below). |
|
| incorrect_text | string | "Wrong." | String to show when the wrong answer is given. Can contain HTML formatting. The special string `%ANS%` can be used within the string. If present, the plugin will put the `text_answer` for the trial in place of the %ANS% string (see example below). |
|
||||||
|
@ -18,7 +18,7 @@ In addition to the [parameters available in all plugins](../overview/plugins.md#
|
|||||||
| left_category_label | string | ['left'] | An array that contains the words/labels associated with a certain stimulus. The labels are aligned to the left side of the page. |
|
| left_category_label | string | ['left'] | An array that contains the words/labels associated with a certain stimulus. The labels are aligned to the left side of the page. |
|
||||||
| right_category_label | string | ['right'] | An array that contains the words/labels associated with a certain stimulus. The labels are aligned to the right side of the page. |
|
| right_category_label | string | ['right'] | An array that contains the words/labels associated with a certain stimulus. The labels are aligned to the right side of the page. |
|
||||||
| stim_key_association | string | *undefined* | Either 'left' or 'right'. This indicates whether the stimulus is associated with the key press and category on the left or right side of the page (`left_category_key` or `right_category_key`). |
|
| stim_key_association | string | *undefined* | Either 'left' or 'right'. This indicates whether the stimulus is associated with the key press and category on the left or right side of the page (`left_category_key` or `right_category_key`). |
|
||||||
| key_to_move_forward | array of strings | jsPsych.ALL_KEYS | This array contains the characters the subject is allowed to press to move on to the next trial if their key press was incorrect and feedback was displayed. Can also have 'other key' as an option which will only allow the user to select the right key to move forward. |
|
| key_to_move_forward | array of strings | "ALL_KEYS" | This array contains the characters the subject is allowed to press to move on to the next trial if their key press was incorrect and feedback was displayed. Can also have 'other key' as an option which will only allow the user to select the right key to move forward. |
|
||||||
| trial_duration | numeric | null | How long to wait for the subject to make a response before ending the trial in milliseconds. If the subject fails to make a response before this timer is reached, the subject's response will be recorded as `null` for the trial and the trial will end. If the value of this parameter is `null`, then the trial will wait for a response indefinitely. |
|
| trial_duration | numeric | null | How long to wait for the subject to make a response before ending the trial in milliseconds. If the subject fails to make a response before this timer is reached, the subject's response will be recorded as `null` for the trial and the trial will end. If the value of this parameter is `null`, then the trial will wait for a response indefinitely. |
|
||||||
| response_ends_trial | boolean | true | If true, then the trial will end whenever the subject makes a response (assuming they make their response before the cutoff specified by the `trial_duration` parameter). If false, then the trial will continue until the value for `trial_duration` is reached. You can use this parameter to force the subject to view a stimulus for a fixed amount of time, even if they respond before the time is complete. |
|
| response_ends_trial | boolean | true | If true, then the trial will end whenever the subject makes a response (assuming they make their response before the cutoff specified by the `trial_duration` parameter). If false, then the trial will continue until the value for `trial_duration` is reached. You can use this parameter to force the subject to view a stimulus for a fixed amount of time, even if they respond before the time is complete. |
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ In addition to the [parameters available in all plugins](../overview/plugins.md#
|
|||||||
| left_category_label | string | ['left'] | An array that contains the words/labels associated with a certain stimulus. The labels are aligned to the left side of the page. |
|
| left_category_label | string | ['left'] | An array that contains the words/labels associated with a certain stimulus. The labels are aligned to the left side of the page. |
|
||||||
| right_category_label | string | ['right'] | An array that contains the words/labels associated with a certain stimulus. The labels are aligned to the right side of the page. |
|
| right_category_label | string | ['right'] | An array that contains the words/labels associated with a certain stimulus. The labels are aligned to the right side of the page. |
|
||||||
| stim_key_association | string | 'undefined' | Either 'left' or 'right'. This indicates whether the stimulus is associated with the key press and category on the left or right side of the page (`left_category_key` or `right_category_key`). |
|
| stim_key_association | string | 'undefined' | Either 'left' or 'right'. This indicates whether the stimulus is associated with the key press and category on the left or right side of the page (`left_category_key` or `right_category_key`). |
|
||||||
| key_to_move_forward | array of characters | jsPsych.ALL_KEYS | This array contains the characters the subject is allowed to press to move on to the next trial if their key press was incorrect and feedback was displayed. Can also have 'other key' as an option which will only allow the user to select the right key to move forward. |
|
| key_to_move_forward | array of characters | "ALL_KEYS" | This array contains the characters the subject is allowed to press to move on to the next trial if their key press was incorrect and feedback was displayed. Can also have 'other key' as an option which will only allow the user to select the right key to move forward. |
|
||||||
| trial_duration | numeric | null | How long to wait for the subject to make a response before ending the trial in milliseconds. If the subject fails to make a response before this timer is reached, the subject's response will be recorded as `null` for the trial and the trial will end. If the value of this parameter is `null`, then the trial will wait for a response indefinitely. |
|
| trial_duration | numeric | null | How long to wait for the subject to make a response before ending the trial in milliseconds. If the subject fails to make a response before this timer is reached, the subject's response will be recorded as `null` for the trial and the trial will end. If the value of this parameter is `null`, then the trial will wait for a response indefinitely. |
|
||||||
| response_ends_trial | boolean | true | If true, then the trial will end whenever the subject makes a response (assuming they make their response before the cutoff specified by the `trial_duration` parameter). If false, then the trial will continue until the value for `trial_duration` is reached. You can use this parameter to force the subject to view a stimulus for a fixed amount of time, even if they respond before the time is complete. |
|
| response_ends_trial | boolean | true | If true, then the trial will end whenever the subject makes a response (assuming they make their response before the cutoff specified by the `trial_duration` parameter). If false, then the trial will continue until the value for `trial_duration` is reached. You can use this parameter to force the subject to view a stimulus for a fixed amount of time, even if they respond before the time is complete. |
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ The keyboard event listener will be bound to the `display_element` declared in `
|
|||||||
|
|
||||||
A valid response triggers the `callback_function` specified in the parameters. A single argument is passed to the callback function. The argument contains an object with the properties `key` and `rt`. `key` contains the string representation of the response key, and `rt` contains the response time.
|
A valid response triggers the `callback_function` specified in the parameters. A single argument is passed to the callback function. The argument contains an object with the properties `key` and `rt`. `key` contains the string representation of the response key, and `rt` contains the response time.
|
||||||
|
|
||||||
This function uses the `.key` value of the keyboard event, which is _case sensitive_. When `case_sensitive_responses` is `false` in `initJsPsych` (the default), this function will convert both the `valid_responses` strings and the response key to lowercase before comparing them, and it will pass the lowercase version of the response key to the `callback_function`. For example, if `valid_responses` is `['a']`, then both 'A' and 'a' will be considered valid key presses, and 'a' will be returned as the response key. When `case_sensitive_responses` is `true` in `initJsPsych`, this function will not convert the case when comparing the `valid_responses` and response key, and it will not convert the case of the response key that is passed to the `callback_function`. For example, if `valid_responses` is `['a']`, then 'a' will be the only valid key press, and 'A' (i.e. 'a' with CapsLock on or Shift held down) will not be accepted. Also, if `valid_responses` includes multiple letter case options (e.g. `jsPsych.ALL_KEYS`), then you may need to check the response key against both letter cases when scoring etc., e.g. `if (response == 'ArrowLeft' || response =='arrowleft') ...`.
|
This function uses the `.key` value of the keyboard event, which is _case sensitive_. When `case_sensitive_responses` is `false` in `initJsPsych` (the default), this function will convert both the `valid_responses` strings and the response key to lowercase before comparing them, and it will pass the lowercase version of the response key to the `callback_function`. For example, if `valid_responses` is `['a']`, then both 'A' and 'a' will be considered valid key presses, and 'a' will be returned as the response key. When `case_sensitive_responses` is `true` in `initJsPsych`, this function will not convert the case when comparing the `valid_responses` and response key, and it will not convert the case of the response key that is passed to the `callback_function`. For example, if `valid_responses` is `['a']`, then 'a' will be the only valid key press, and 'A' (i.e. 'a' with CapsLock on or Shift held down) will not be accepted. Also, if `valid_responses` includes multiple letter case options (e.g. `"ALL_KEYS"`), then you may need to check the response key against both letter cases when scoring etc., e.g. `if (response == 'ArrowLeft' || response =='arrowleft') ...`.
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ var after_response = function(info){
|
|||||||
|
|
||||||
jsPsych.pluginAPI.getKeyboardResponse({
|
jsPsych.pluginAPI.getKeyboardResponse({
|
||||||
callback_function:after_response,
|
callback_function:after_response,
|
||||||
valid_responses: jsPsych.ALL_KEYS,
|
valid_responses: "ALL_KEYS",
|
||||||
rt_method: 'performance',
|
rt_method: 'performance',
|
||||||
persist: false
|
persist: false
|
||||||
});
|
});
|
||||||
@ -338,7 +338,7 @@ var after_response = function(info){
|
|||||||
|
|
||||||
var listener = jsPsych.pluginAPI.getKeyboardResponse({
|
var listener = jsPsych.pluginAPI.getKeyboardResponse({
|
||||||
callback_function:after_response,
|
callback_function:after_response,
|
||||||
valid_responses: jsPsych.ALL_KEYS,
|
valid_responses: "ALL_KEYS",
|
||||||
rt_method: 'performance',
|
rt_method: 'performance',
|
||||||
persist: true
|
persist: true
|
||||||
});
|
});
|
||||||
|
@ -458,13 +458,13 @@ var test_stimuli = [
|
|||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
Instead of just showing the blue and orange circles, let's also set up the experiment to show a fixation cross (+) in between trials. We can define a trial to show the fixation cross for a fixed amount of time by using the `trial_duration` parameter of the html-keyboard-response plugin and setting the `choices` parameter to the special value `jsPsych.NO_KEYS`, which means that no responses will be accepted as a valid response and the trial will last however long the `trial_duration` parameter specifies.
|
Instead of just showing the blue and orange circles, let's also set up the experiment to show a fixation cross (+) in between trials. We can define a trial to show the fixation cross for a fixed amount of time by using the `trial_duration` parameter of the html-keyboard-response plugin and setting the `choices` parameter to the special value `"NO_KEYS"`, which means that no responses will be accepted as a valid response and the trial will last however long the `trial_duration` parameter specifies.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var fixation = {
|
var fixation = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '<div style="font-size:60px;">+</div>',
|
stimulus: '<div style="font-size:60px;">+</div>',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: 1000,
|
trial_duration: 1000,
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
@ -563,7 +563,7 @@ What happens when the experiment reaches the test procedure? jsPsych will run th
|
|||||||
var fixation = {
|
var fixation = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '<div style="font-size:60px;">+</div>',
|
stimulus: '<div style="font-size:60px;">+</div>',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: 1000,
|
trial_duration: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -677,7 +677,7 @@ var test_procedure = {
|
|||||||
var fixation = {
|
var fixation = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '<div style="font-size:60px;">+</div>',
|
stimulus: '<div style="font-size:60px;">+</div>',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: 1000,
|
trial_duration: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -713,7 +713,7 @@ To do that here, we'll use one of the built-in randomization methods in [jsPsych
|
|||||||
var fixation = {
|
var fixation = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '<div style="font-size:60px;">+</div>',
|
stimulus: '<div style="font-size:60px;">+</div>',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: function(){
|
trial_duration: function(){
|
||||||
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
||||||
}
|
}
|
||||||
@ -789,7 +789,7 @@ In the code above, we replaced the `trial_duration: 1000` parameter in `fixation
|
|||||||
var fixation = {
|
var fixation = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '<div style="font-size:60px;">+</div>',
|
stimulus: '<div style="font-size:60px;">+</div>',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: function(){
|
trial_duration: function(){
|
||||||
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
||||||
}
|
}
|
||||||
@ -902,7 +902,7 @@ var jsPsych = initJsPsych({
|
|||||||
var fixation = {
|
var fixation = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '<div style="font-size:60px;">+</div>',
|
stimulus: '<div style="font-size:60px;">+</div>',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: function(){
|
trial_duration: function(){
|
||||||
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
||||||
}
|
}
|
||||||
@ -978,7 +978,7 @@ Another kind of tagging that would be useful is to mark each fixation trial as s
|
|||||||
var fixation = {
|
var fixation = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '<div style="font-size:60px;">+</div>',
|
stimulus: '<div style="font-size:60px;">+</div>',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: function(){
|
trial_duration: function(){
|
||||||
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
||||||
},
|
},
|
||||||
@ -1059,7 +1059,7 @@ var fixation = {
|
|||||||
var fixation = {
|
var fixation = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '<div style="font-size:60px;">+</div>',
|
stimulus: '<div style="font-size:60px;">+</div>',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: function(){
|
trial_duration: function(){
|
||||||
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
||||||
},
|
},
|
||||||
@ -1198,7 +1198,7 @@ The `data.response` value is a string representation of the key the subject pres
|
|||||||
var fixation = {
|
var fixation = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '<div style="font-size:60px;">+</div>',
|
stimulus: '<div style="font-size:60px;">+</div>',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: function(){
|
trial_duration: function(){
|
||||||
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
||||||
},
|
},
|
||||||
@ -1348,7 +1348,7 @@ This code is available in the `/examples` folder in the jsPsych release download
|
|||||||
var fixation = {
|
var fixation = {
|
||||||
type: jsPsychHtmlKeyboardResponse,
|
type: jsPsychHtmlKeyboardResponse,
|
||||||
stimulus: '<div style="font-size:60px;">+</div>',
|
stimulus: '<div style="font-size:60px;">+</div>',
|
||||||
choices: jsPsych.NO_KEYS,
|
choices: "NO_KEYS",
|
||||||
trial_duration: function(){
|
trial_duration: function(){
|
||||||
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
return jsPsych.randomization.sampleWithoutReplacement([250, 500, 750, 1000, 1250, 1500, 1750, 2000], 1)[0];
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user