@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/README.md +8 -2
- package/dist/index.browser.js +174 -167
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +2 -2
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +172 -165
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +180 -126
- package/dist/index.js +172 -165
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.spec.ts +7 -6
- package/src/index.ts +44 -23
package/dist/index.d.ts
CHANGED
|
@@ -1,126 +1,180 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
readonly
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
readonly
|
|
25
|
-
readonly type: ParameterType.
|
|
26
|
-
readonly
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
readonly
|
|
35
|
-
readonly default: any;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* How long to
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
readonly
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
readonly
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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 };
|