Allow responses from button or keyboard? #1825
-
I want to allow responses from both html buttons and the keyboard. Should I try to add keyboard input to html-button-response, Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
EDIT: Sorry, one last step that I forgot to mention. At the end of the trial you have to clear the keyboard listener so that it doesn't continue running during subsequent trials. You can do this in the Hi @AlecMRogers, sorry for the slow response! Not sure if this is still useful... Unfortunately there's no other option (that I know of) to combine button and keyboard responses - I think you'll have to add one of the response options to a plugin that allows the other type of response. If it were me, I would probably add a keyboard listener to the button response plugin.
jsPsych.pluginAPI.getKeyboardResponse({
callback_function: after_response,
valid_responses: trial.key_choices,
rt_method: 'performance',
persist: false
}); Where I think that's it. Let us know if you've got it working, and feel free to follow up here if you need further guidance. |
Beta Was this translation helpful? Give feedback.
EDIT: Sorry, one last step that I forgot to mention. At the end of the trial you have to clear the keyboard listener so that it doesn't continue running during subsequent trials. You can do this in the
end_trial
function using thejsPsych.pluginAPI.cancelAllKeyboardResponses()
function. Or if you assigngetKeyboardResponse
to a variable (e.g.listener_id
) then you can clear that one specifically withjsPsych.pluginAPI.cancelKeyboardResponse(listener_id)
.Hi @AlecMRogers, sorry for the slow response! Not sure if this is still useful...
Unfortunately there's no other option (that I know of) to combine button and keyboard responses - I think you'll have to add one of the response options to…