Comments (2)
Of course it is possible, but not with jsPsych's API. I think you would have to write your own keyboard listeners, like the example below:
let jsPsych = initJsPsych({
on_finish: function () {
jsPsych.data.displayData();
},
});
let trial = {
type: jsPsychHtmlKeyboardResponse,
stimulus: 'Press F',
choices: 'NO_KEYS',
on_load: function () {
let time_start = performance.now();
let key_down, key_up;
function keydown_listener(ev) {
if (ev.key.toLowerCase() === 'f' && !ev.repeat) {
key_down = performance.now() - time_start;
}
}
function keyup_listener(ev) {
if (ev.key.toLowerCase() === 'f' && typeof key_down !== 'undefined') {
key_up = performance.now() - time_start;
jsPsych.finishTrial({key_down, key_up});
document.body.removeEventListener('keydown', keydown_listener);
document.body.removeEventListener('keyup', keyup_listener);
}
}
document.body.addEventListener('keydown', keydown_listener);
document.body.addEventListener('keyup', keyup_listener);
},
};
jsPsych.run([trial]);
from jspsych.
Ah I see, thanks a lot for your help @Shaobin-Jiang !
from jspsych.
Related Issues (20)
- docs website: plugins list grouping?
- MathJax for html in jsPsych (v7.1)? HOT 2
- randomize_statement_order in likert-table in survey plugin not working HOT 1
- Unable to run jsPsych in node.js HOT 2
- Customize Display Element Wrapper ID HOT 3
- Edit button colour after selection HOT 6
- Audio snippet not working in Firefox HOT 3
- Add community tutorials to documentation HOT 1
- support tick marks in -slider-reponse
- randomise within the timeline HOT 1
- Eye Tracking example url redirect to the wrong url HOT 1
- Add DataPipe file saving example to `survey` docs/examples
- Add section on CSS customization to `survey` plugin docs
- Extending video recording extension HOT 9
- How could I change the label text for IAT-plugin? HOT 4
- incorrect width for jsPsychSurvey dropdown options
- How to set "stim_key_association" as a variable in IAT-plugin? HOT 2
- [Feature Add] Add a new attribute to allow the plugin "html-button-response" to delay the display of the button HOT 7
- Check jspsych.org configuration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jspsych.