0.1.0 • Published 11 months ago
@pcllab/plugin-audio-response v0.1.0
audio-response-plugin
This is an audio response plugin that can accept button and keyboard responses.
It is a combination of jsPsych's audio-keyboard-response and audio-button-response plugins.
Install
With NPM:
npm i @pcllab/plugin-audio-response
import audioResponse from "@pcllab/plugin-audio-response";
With CDN:
Other dependencies (react, react-dom, tailwind) need to loaded separately.
<script src="https://unpkg.com/@pcllab/plugin-audio-response"></script>
Use
const trial = {
type: audioResponse,
stimulus: "audio.mp3"
keyboard: {
choices: ["y", "n"]
}
button: {
choices: ["Yes", "No"]
}
};
Parameters
Parameter | Type | Description | Examples |
---|---|---|---|
keyboard | object | Allow keyboard responses | (default)undefined {} |
keyboard.choices | string[] | "ALL_KEYS" | "NO_KEYS" | Restrict keyboard responses | (default)ALL_KEYS ["y", "n"] |
button | object | Allow button responses | (default)undefined {} |
button.choices | string[] | Button text | (default)undefined ["y", "n"] |
button.html | string | string[] | One HTML string for all buttons or list of strings to use for each choice, where %choice% is replaced by the corresponding choice. | (default)"<button class="jspsych-btn">%choice%</button>" ["<button class="custom-class">1. %choice%</button>", "<button class="custom-class">2. %choice%</button>"] |
button.margin_vertical | string | Vertical padding style value | (default)"0px" "12px" |
button.margin_horizontal | string | Horizontal padding style value | (default)"8px" "0px" |
prompt | html string | Arbitrary HTML to show above the input | (default)"" <h1>Here is a prompt </h1> |
Data Generated
In addition to the default data collected by all plugins, this plugin collects the following data.
Name | Type | Value |
---|---|---|
response | string | The button choice or key pressed |
rt | number | Time in ms between audio starting and response |