Record first keypress and RT #3193
-
I've been using the survey-html-form plugin for a stem completion task e.g., complete the word: rea____ I want to record the first keypress and the RT for that keypress. Right now, the RT that's recorded is the time it takes for them to submit the response. |
Beta Was this translation helpful? Give feedback.
Answered by
ChristopheBossens
Dec 8, 2023
Replies: 1 comment 4 replies
-
I think you can achieve this by using the let first_key_info;
function first_keypress(info){
console.log(info);
first_key_info = info;
}
var trial = {
type: jsPsychSurveyHtmlForm,
preamble: '<p>How are you feeling <b>right now?</b></p>',
html: '<p> I am feeling <input name="first" type="text" />, <input name="second" type="text" />, and <input name="third" type="text" />.</p>',
on_start : function(){
jsPsych.pluginAPI.getKeyboardResponse({
callback_function: first_keypress,
valid_responses : "ALL_KEYS",
rt_method: "performance",
persist: false
});
},
on_finish : function(data){
data.first_key_info = first_key_info;
}
}; Is this what you need? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good catch, did not think about that :)
I checked the source code and the getKeyboardResponse indeed does not propagate the event. I think your solution will always but the first keypress in the first input field, even if a participant has a focus in the second input field? For future reference I adjusted the code a little bit so that it works irrespective of the input field