@jspsych/plugin-image-keyboard-response 1.1.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,150 +1,193 @@
1
- import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "jspsych";
1
+ import { JsPsychPlugin, ParameterType, JsPsych, TrialType } from 'jspsych';
2
+
2
3
  declare const info: {
3
4
  readonly name: "image-keyboard-response";
5
+ readonly version: string;
4
6
  readonly parameters: {
5
- /** The image to be displayed */
7
+ /** The path of the image file to be displayed. */
6
8
  readonly stimulus: {
7
9
  readonly type: ParameterType.IMAGE;
8
- readonly pretty_name: "Stimulus";
9
10
  readonly default: any;
10
11
  };
11
- /** Set the image height in pixels */
12
+ /** Set the height of the image in pixels. If left null (no value specified), then the image will display at its natural height. */
12
13
  readonly stimulus_height: {
13
14
  readonly type: ParameterType.INT;
14
- readonly pretty_name: "Image height";
15
15
  readonly default: any;
16
16
  };
17
- /** Set the image width in pixels */
17
+ /** Set the width of the image in pixels. If left null (no value specified), then the image will display at its natural width. */
18
18
  readonly stimulus_width: {
19
19
  readonly type: ParameterType.INT;
20
- readonly pretty_name: "Image width";
21
20
  readonly default: any;
22
21
  };
23
- /** Maintain the aspect ratio after setting width or height */
22
+ /** If setting *only* the width or *only* the height and this parameter is true, then the other dimension will be scaled
23
+ * to maintain the image's aspect ratio. */
24
24
  readonly maintain_aspect_ratio: {
25
25
  readonly type: ParameterType.BOOL;
26
- readonly pretty_name: "Maintain aspect ratio";
27
26
  readonly default: true;
28
27
  };
29
- /** Array containing the key(s) the subject is allowed to press to respond to the stimulus. */
28
+ /**his array contains the key(s) that the participant is allowed to press in order to respond to the stimulus. Keys should
29
+ * be specified as characters (e.g., `'a'`, `'q'`, `' '`, `'Enter'`, `'ArrowDown'`) - see
30
+ * [this page](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) and
31
+ * [this page (event.key column)](https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/)
32
+ * for more examples. Any key presses that are not listed in the array will be ignored. The default value of `"ALL_KEYS"`
33
+ * means that all keys will be accepted as valid responses. Specifying `"NO_KEYS"` will mean that no responses are allowed. */
30
34
  readonly choices: {
31
35
  readonly type: ParameterType.KEYS;
32
- readonly pretty_name: "Choices";
33
36
  readonly default: "ALL_KEYS";
34
37
  };
35
- /** Any content here will be displayed below the stimulus. */
38
+ /**This string can contain HTML markup. Any content here will be displayed below the stimulus. The intention is that it can
39
+ * be used to provide a reminder about the action the participant is supposed to take (e.g., which key to press). */
36
40
  readonly prompt: {
37
41
  readonly type: ParameterType.HTML_STRING;
38
- readonly pretty_name: "Prompt";
39
42
  readonly default: any;
40
43
  };
41
- /** How long to show the stimulus. */
44
+ /** How long to show the stimulus for in milliseconds. If the value is `null`, then the stimulus will be shown until the
45
+ * participant makes a response. */
42
46
  readonly stimulus_duration: {
43
47
  readonly type: ParameterType.INT;
44
- readonly pretty_name: "Stimulus duration";
45
48
  readonly default: any;
46
49
  };
47
- /** How long to show trial before it ends */
50
+ /** How long to wait for the participant to make a response before ending the trial in milliseconds. If the participant
51
+ * fails to make a response before this timer is reached, the participant's response will be recorded as null for the
52
+ * trial and the trial will end. If the value of this parameter is `null`, then the trial will wait for a response indefinitely. */
48
53
  readonly trial_duration: {
49
54
  readonly type: ParameterType.INT;
50
- readonly pretty_name: "Trial duration";
51
55
  readonly default: any;
52
56
  };
53
- /** If true, trial will end when subject makes a response. */
57
+ /** If true, then the trial will end whenever the participant makes a response (assuming they make their response before
58
+ * the cutoff specified by the `trial_duration` parameter). If false, then the trial will continue until the value for
59
+ * `trial_duration` is reached. You can set this parameter to `false` to force the participant to view a stimulus for a
60
+ * fixed amount of time, even if they respond before the time is complete. */
54
61
  readonly response_ends_trial: {
55
62
  readonly type: ParameterType.BOOL;
56
- readonly pretty_name: "Response ends trial";
57
63
  readonly default: true;
58
64
  };
59
65
  /**
60
- * If true, the image will be drawn onto a canvas element (prevents blank screen between consecutive images in some browsers).
61
- * If false, the image will be shown via an img element.
66
+ * If `true`, the image will be drawn onto a canvas element. This prevents a blank screen (white flash) between consecutive image trials in some browsers, like Firefox and Edge.
67
+ * If `false`, the image will be shown via an img element, as in previous versions of jsPsych. If the stimulus is an **animated gif**, you must set this parameter to false, because the canvas rendering method will only present static images.
62
68
  */
63
69
  readonly render_on_canvas: {
64
70
  readonly type: ParameterType.BOOL;
65
- readonly pretty_name: "Render on canvas";
66
71
  readonly default: true;
67
72
  };
68
73
  };
74
+ readonly data: {
75
+ /** The path of the image that was displayed. */
76
+ readonly stimulus: {
77
+ readonly type: ParameterType.STRING;
78
+ };
79
+ /** Indicates which key the participant pressed. */
80
+ readonly response: {
81
+ readonly type: ParameterType.STRING;
82
+ };
83
+ /** The response time in milliseconds for the participant to make a response. The time is measured from when the stimulus
84
+ * first appears on the screen until the participant's response. */
85
+ readonly rt: {
86
+ readonly type: ParameterType.INT;
87
+ };
88
+ };
69
89
  };
70
90
  type Info = typeof info;
71
91
  /**
72
- * **image-keyboard-response**
92
+ * This plugin displays an image and records responses generated with the keyboard. The stimulus can be displayed until a
93
+ * response is given, or for a pre-determined amount of time. The trial can be ended automatically if the participant has
94
+ * failed to respond within a fixed length of time.
73
95
  *
74
- * jsPsych plugin for displaying an image stimulus and getting a keyboard response
96
+ * Image files can be automatically preloaded by jsPsych using the [`preload` plugin](preload.md). However, if you are using
97
+ * timeline variables or another dynamic method to specify the image stimulus, you will need to
98
+ * [manually preload](../overview/media-preloading.md#manual-preloading) the images.
75
99
  *
76
100
  * @author Josh de Leeuw
77
- * @see {@link https://www.jspsych.org/plugins/jspsych-image-keyboard-response/ image-keyboard-response plugin documentation on jspsych.org}
101
+ * @see {@link https://www.jspsych.org/latest/plugins/image-keyboard-response/ image-keyboard-response plugin documentation on jspsych.org}
78
102
  */
79
103
  declare class ImageKeyboardResponsePlugin implements JsPsychPlugin<Info> {
80
104
  private jsPsych;
81
105
  static info: {
82
106
  readonly name: "image-keyboard-response";
107
+ readonly version: string;
83
108
  readonly parameters: {
84
- /** The image to be displayed */
109
+ /** The path of the image file to be displayed. */
85
110
  readonly stimulus: {
86
111
  readonly type: ParameterType.IMAGE;
87
- readonly pretty_name: "Stimulus";
88
112
  readonly default: any;
89
113
  };
90
- /** Set the image height in pixels */
114
+ /** Set the height of the image in pixels. If left null (no value specified), then the image will display at its natural height. */
91
115
  readonly stimulus_height: {
92
116
  readonly type: ParameterType.INT;
93
- readonly pretty_name: "Image height";
94
117
  readonly default: any;
95
118
  };
96
- /** Set the image width in pixels */
119
+ /** Set the width of the image in pixels. If left null (no value specified), then the image will display at its natural width. */
97
120
  readonly stimulus_width: {
98
121
  readonly type: ParameterType.INT;
99
- readonly pretty_name: "Image width";
100
122
  readonly default: any;
101
123
  };
102
- /** Maintain the aspect ratio after setting width or height */
124
+ /** If setting *only* the width or *only* the height and this parameter is true, then the other dimension will be scaled
125
+ * to maintain the image's aspect ratio. */
103
126
  readonly maintain_aspect_ratio: {
104
127
  readonly type: ParameterType.BOOL;
105
- readonly pretty_name: "Maintain aspect ratio";
106
128
  readonly default: true;
107
129
  };
108
- /** Array containing the key(s) the subject is allowed to press to respond to the stimulus. */
130
+ /**his array contains the key(s) that the participant is allowed to press in order to respond to the stimulus. Keys should
131
+ * be specified as characters (e.g., `'a'`, `'q'`, `' '`, `'Enter'`, `'ArrowDown'`) - see
132
+ * [this page](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) and
133
+ * [this page (event.key column)](https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/)
134
+ * for more examples. Any key presses that are not listed in the array will be ignored. The default value of `"ALL_KEYS"`
135
+ * means that all keys will be accepted as valid responses. Specifying `"NO_KEYS"` will mean that no responses are allowed. */
109
136
  readonly choices: {
110
137
  readonly type: ParameterType.KEYS;
111
- readonly pretty_name: "Choices";
112
138
  readonly default: "ALL_KEYS";
113
139
  };
114
- /** Any content here will be displayed below the stimulus. */
140
+ /**This string can contain HTML markup. Any content here will be displayed below the stimulus. The intention is that it can
141
+ * be used to provide a reminder about the action the participant is supposed to take (e.g., which key to press). */
115
142
  readonly prompt: {
116
143
  readonly type: ParameterType.HTML_STRING;
117
- readonly pretty_name: "Prompt";
118
144
  readonly default: any;
119
145
  };
120
- /** How long to show the stimulus. */
146
+ /** How long to show the stimulus for in milliseconds. If the value is `null`, then the stimulus will be shown until the
147
+ * participant makes a response. */
121
148
  readonly stimulus_duration: {
122
149
  readonly type: ParameterType.INT;
123
- readonly pretty_name: "Stimulus duration";
124
150
  readonly default: any;
125
151
  };
126
- /** How long to show trial before it ends */
152
+ /** How long to wait for the participant to make a response before ending the trial in milliseconds. If the participant
153
+ * fails to make a response before this timer is reached, the participant's response will be recorded as null for the
154
+ * trial and the trial will end. If the value of this parameter is `null`, then the trial will wait for a response indefinitely. */
127
155
  readonly trial_duration: {
128
156
  readonly type: ParameterType.INT;
129
- readonly pretty_name: "Trial duration";
130
157
  readonly default: any;
131
158
  };
132
- /** If true, trial will end when subject makes a response. */
159
+ /** If true, then the trial will end whenever the participant makes a response (assuming they make their response before
160
+ * the cutoff specified by the `trial_duration` parameter). If false, then the trial will continue until the value for
161
+ * `trial_duration` is reached. You can set this parameter to `false` to force the participant to view a stimulus for a
162
+ * fixed amount of time, even if they respond before the time is complete. */
133
163
  readonly response_ends_trial: {
134
164
  readonly type: ParameterType.BOOL;
135
- readonly pretty_name: "Response ends trial";
136
165
  readonly default: true;
137
166
  };
138
167
  /**
139
- * If true, the image will be drawn onto a canvas element (prevents blank screen between consecutive images in some browsers).
140
- * If false, the image will be shown via an img element.
168
+ * If `true`, the image will be drawn onto a canvas element. This prevents a blank screen (white flash) between consecutive image trials in some browsers, like Firefox and Edge.
169
+ * If `false`, the image will be shown via an img element, as in previous versions of jsPsych. If the stimulus is an **animated gif**, you must set this parameter to false, because the canvas rendering method will only present static images.
141
170
  */
142
171
  readonly render_on_canvas: {
143
172
  readonly type: ParameterType.BOOL;
144
- readonly pretty_name: "Render on canvas";
145
173
  readonly default: true;
146
174
  };
147
175
  };
176
+ readonly data: {
177
+ /** The path of the image that was displayed. */
178
+ readonly stimulus: {
179
+ readonly type: ParameterType.STRING;
180
+ };
181
+ /** Indicates which key the participant pressed. */
182
+ readonly response: {
183
+ readonly type: ParameterType.STRING;
184
+ };
185
+ /** The response time in milliseconds for the participant to make a response. The time is measured from when the stimulus
186
+ * first appears on the screen until the participant's response. */
187
+ readonly rt: {
188
+ readonly type: ParameterType.INT;
189
+ };
190
+ };
148
191
  };
149
192
  constructor(jsPsych: JsPsych);
150
193
  trial(display_element: HTMLElement, trial: TrialType<Info>): void;
@@ -153,4 +196,5 @@ declare class ImageKeyboardResponsePlugin implements JsPsychPlugin<Info> {
153
196
  private simulate_visual;
154
197
  private create_simulation_data;
155
198
  }
156
- export default ImageKeyboardResponsePlugin;
199
+
200
+ export { ImageKeyboardResponsePlugin as default };