@jspsych/plugin-html-keyboard-response 1.1.2 → 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,126 +1,180 @@
1
- import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "jspsych";
2
- declare const info: {
3
- readonly name: "html-keyboard-response";
4
- readonly parameters: {
5
- /**
6
- * The HTML string to be displayed.
7
- */
8
- readonly stimulus: {
9
- readonly type: ParameterType.HTML_STRING;
10
- readonly pretty_name: "Stimulus";
11
- readonly default: any;
12
- };
13
- /**
14
- * Array containing the key(s) the subject is allowed to press to respond to the stimulus.
15
- */
16
- readonly choices: {
17
- readonly type: ParameterType.KEYS;
18
- readonly pretty_name: "Choices";
19
- readonly default: "ALL_KEYS";
20
- };
21
- /**
22
- * Any content here will be displayed below the stimulus.
23
- */
24
- readonly prompt: {
25
- readonly type: ParameterType.HTML_STRING;
26
- readonly pretty_name: "Prompt";
27
- readonly default: any;
28
- };
29
- /**
30
- * How long to show the stimulus.
31
- */
32
- readonly stimulus_duration: {
33
- readonly type: ParameterType.INT;
34
- readonly pretty_name: "Stimulus duration";
35
- readonly default: any;
36
- };
37
- /**
38
- * How long to show trial before it ends.
39
- */
40
- readonly trial_duration: {
41
- readonly type: ParameterType.INT;
42
- readonly pretty_name: "Trial duration";
43
- readonly default: any;
44
- };
45
- /**
46
- * If true, trial will end when subject makes a response.
47
- */
48
- readonly response_ends_trial: {
49
- readonly type: ParameterType.BOOL;
50
- readonly pretty_name: "Response ends trial";
51
- readonly default: true;
52
- };
53
- };
54
- };
55
- declare type Info = typeof info;
56
- /**
57
- * **html-keyboard-response**
58
- *
59
- * jsPsych plugin for displaying a stimulus and getting a keyboard response
60
- *
61
- * @author Josh de Leeuw
62
- * @see {@link https://www.jspsych.org/plugins/jspsych-html-keyboard-response/ html-keyboard-response plugin documentation on jspsych.org}
63
- */
64
- declare class HtmlKeyboardResponsePlugin implements JsPsychPlugin<Info> {
65
- private jsPsych;
66
- static info: {
67
- readonly name: "html-keyboard-response";
68
- readonly parameters: {
69
- /**
70
- * The HTML string to be displayed.
71
- */
72
- readonly stimulus: {
73
- readonly type: ParameterType.HTML_STRING;
74
- readonly pretty_name: "Stimulus";
75
- readonly default: any;
76
- };
77
- /**
78
- * Array containing the key(s) the subject is allowed to press to respond to the stimulus.
79
- */
80
- readonly choices: {
81
- readonly type: ParameterType.KEYS;
82
- readonly pretty_name: "Choices";
83
- readonly default: "ALL_KEYS";
84
- };
85
- /**
86
- * Any content here will be displayed below the stimulus.
87
- */
88
- readonly prompt: {
89
- readonly type: ParameterType.HTML_STRING;
90
- readonly pretty_name: "Prompt";
91
- readonly default: any;
92
- };
93
- /**
94
- * How long to show the stimulus.
95
- */
96
- readonly stimulus_duration: {
97
- readonly type: ParameterType.INT;
98
- readonly pretty_name: "Stimulus duration";
99
- readonly default: any;
100
- };
101
- /**
102
- * How long to show trial before it ends.
103
- */
104
- readonly trial_duration: {
105
- readonly type: ParameterType.INT;
106
- readonly pretty_name: "Trial duration";
107
- readonly default: any;
108
- };
109
- /**
110
- * If true, trial will end when subject makes a response.
111
- */
112
- readonly response_ends_trial: {
113
- readonly type: ParameterType.BOOL;
114
- readonly pretty_name: "Response ends trial";
115
- readonly default: true;
116
- };
117
- };
118
- };
119
- constructor(jsPsych: JsPsych);
120
- trial(display_element: HTMLElement, trial: TrialType<Info>): void;
121
- simulate(trial: TrialType<Info>, simulation_mode: any, simulation_options: any, load_callback: () => void): void;
122
- private create_simulation_data;
123
- private simulate_data_only;
124
- private simulate_visual;
125
- }
126
- export default HtmlKeyboardResponsePlugin;
1
+ import { JsPsychPlugin, ParameterType, JsPsych, TrialType } from 'jspsych';
2
+
3
+ declare const info: {
4
+ readonly name: "html-keyboard-response";
5
+ readonly version: string;
6
+ readonly parameters: {
7
+ /**
8
+ * The string to be displayed.
9
+ */
10
+ readonly stimulus: {
11
+ readonly type: ParameterType.HTML_STRING;
12
+ readonly default: any;
13
+ };
14
+ /**
15
+ * This array contains the key(s) that the participant is allowed to press in order to respond
16
+ * to the stimulus. Keys should be specified as characters (e.g., `'a'`, `'q'`, `' '`, `'Enter'`, `'ArrowDown'`) - see
17
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values this page}
18
+ * and
19
+ * {@link https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/ this page (event.key column)}
20
+ * for more examples. Any key presses that are not listed in the
21
+ * array will be ignored. The default value of `"ALL_KEYS"` means that all keys will be accepted as valid responses.
22
+ * Specifying `"NO_KEYS"` will mean that no responses are allowed.
23
+ */
24
+ readonly choices: {
25
+ readonly type: ParameterType.KEYS;
26
+ readonly default: "ALL_KEYS";
27
+ };
28
+ /**
29
+ * This string can contain HTML markup. Any content here will be displayed below the stimulus.
30
+ * The intention is that it can be used to provide a reminder about the action the participant
31
+ * is supposed to take (e.g., which key to press).
32
+ */
33
+ readonly prompt: {
34
+ readonly type: ParameterType.HTML_STRING;
35
+ readonly default: any;
36
+ };
37
+ /**
38
+ * How long to display the stimulus in milliseconds. The visibility CSS property of the stimulus
39
+ * will be set to `hidden` after this time has elapsed. If this is null, then the stimulus will
40
+ * remain visible until the trial ends.
41
+ */
42
+ readonly stimulus_duration: {
43
+ readonly type: ParameterType.INT;
44
+ readonly default: any;
45
+ };
46
+ /**
47
+ * How long to wait for the participant to make a response before ending the trial in milliseconds.
48
+ * If the participant fails to make a response before this timer is reached, the participant's response
49
+ * will be recorded as null for the trial and the trial will end. If the value of this parameter is null,
50
+ * then the trial will wait for a response indefinitely.
51
+ */
52
+ readonly trial_duration: {
53
+ readonly type: ParameterType.INT;
54
+ readonly default: any;
55
+ };
56
+ /**
57
+ * If true, then the trial will end whenever the participant makes a response (assuming they make their
58
+ * response before the cutoff specified by the trial_duration parameter). If false, then the trial will
59
+ * continue until the value for trial_duration is reached. You can set this parameter to false to force
60
+ * the participant to view a stimulus for a fixed amount of time, even if they respond before the time is complete.
61
+ */
62
+ readonly response_ends_trial: {
63
+ readonly type: ParameterType.BOOL;
64
+ readonly default: true;
65
+ };
66
+ };
67
+ readonly data: {
68
+ /** Indicates which key the participant pressed. */
69
+ readonly response: {
70
+ readonly type: ParameterType.STRING;
71
+ };
72
+ /** The response time in milliseconds for the participant to make a response. The time is measured from when the stimulus first appears on the screen until the participant's response. */
73
+ readonly rt: {
74
+ readonly type: ParameterType.INT;
75
+ };
76
+ /** The HTML content that was displayed on the screen. */
77
+ readonly stimulus: {
78
+ readonly type: ParameterType.STRING;
79
+ };
80
+ };
81
+ };
82
+ type Info = typeof info;
83
+ /**
84
+ * This plugin displays HTML content and records responses generated with the keyboard.
85
+ * The stimulus can be displayed until a response is given, or for a pre-determined amount of time.
86
+ * The trial can be ended automatically if the participant has failed to respond within a fixed length of time.
87
+ *
88
+ * @author Josh de Leeuw
89
+ * @see {@link https://www.jspsych.org/latest/plugins/html-keyboard-response/ html-keyboard-response plugin documentation on jspsych.org}
90
+ */
91
+ declare class HtmlKeyboardResponsePlugin implements JsPsychPlugin<Info> {
92
+ private jsPsych;
93
+ static info: {
94
+ readonly name: "html-keyboard-response";
95
+ readonly version: string;
96
+ readonly parameters: {
97
+ /**
98
+ * The string to be displayed.
99
+ */
100
+ readonly stimulus: {
101
+ readonly type: ParameterType.HTML_STRING;
102
+ readonly default: any;
103
+ };
104
+ /**
105
+ * This array contains the key(s) that the participant is allowed to press in order to respond
106
+ * to the stimulus. Keys should be specified as characters (e.g., `'a'`, `'q'`, `' '`, `'Enter'`, `'ArrowDown'`) - see
107
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values this page}
108
+ * and
109
+ * {@link https://www.freecodecamp.org/news/javascript-keycode-list-keypress-event-key-codes/ this page (event.key column)}
110
+ * for more examples. Any key presses that are not listed in the
111
+ * array will be ignored. The default value of `"ALL_KEYS"` means that all keys will be accepted as valid responses.
112
+ * Specifying `"NO_KEYS"` will mean that no responses are allowed.
113
+ */
114
+ readonly choices: {
115
+ readonly type: ParameterType.KEYS;
116
+ readonly default: "ALL_KEYS";
117
+ };
118
+ /**
119
+ * This string can contain HTML markup. Any content here will be displayed below the stimulus.
120
+ * The intention is that it can be used to provide a reminder about the action the participant
121
+ * is supposed to take (e.g., which key to press).
122
+ */
123
+ readonly prompt: {
124
+ readonly type: ParameterType.HTML_STRING;
125
+ readonly default: any;
126
+ };
127
+ /**
128
+ * How long to display the stimulus in milliseconds. The visibility CSS property of the stimulus
129
+ * will be set to `hidden` after this time has elapsed. If this is null, then the stimulus will
130
+ * remain visible until the trial ends.
131
+ */
132
+ readonly stimulus_duration: {
133
+ readonly type: ParameterType.INT;
134
+ readonly default: any;
135
+ };
136
+ /**
137
+ * How long to wait for the participant to make a response before ending the trial in milliseconds.
138
+ * If the participant fails to make a response before this timer is reached, the participant's response
139
+ * will be recorded as null for the trial and the trial will end. If the value of this parameter is null,
140
+ * then the trial will wait for a response indefinitely.
141
+ */
142
+ readonly trial_duration: {
143
+ readonly type: ParameterType.INT;
144
+ readonly default: any;
145
+ };
146
+ /**
147
+ * If true, then the trial will end whenever the participant makes a response (assuming they make their
148
+ * response before the cutoff specified by the trial_duration parameter). If false, then the trial will
149
+ * continue until the value for trial_duration is reached. You can set this parameter to false to force
150
+ * the participant to view a stimulus for a fixed amount of time, even if they respond before the time is complete.
151
+ */
152
+ readonly response_ends_trial: {
153
+ readonly type: ParameterType.BOOL;
154
+ readonly default: true;
155
+ };
156
+ };
157
+ readonly data: {
158
+ /** Indicates which key the participant pressed. */
159
+ readonly response: {
160
+ readonly type: ParameterType.STRING;
161
+ };
162
+ /** The response time in milliseconds for the participant to make a response. The time is measured from when the stimulus first appears on the screen until the participant's response. */
163
+ readonly rt: {
164
+ readonly type: ParameterType.INT;
165
+ };
166
+ /** The HTML content that was displayed on the screen. */
167
+ readonly stimulus: {
168
+ readonly type: ParameterType.STRING;
169
+ };
170
+ };
171
+ };
172
+ constructor(jsPsych: JsPsych);
173
+ trial(display_element: HTMLElement, trial: TrialType<Info>): void;
174
+ simulate(trial: TrialType<Info>, simulation_mode: any, simulation_options: any, load_callback: () => void): void;
175
+ private create_simulation_data;
176
+ private simulate_data_only;
177
+ private simulate_visual;
178
+ }
179
+
180
+ export { HtmlKeyboardResponsePlugin as default };