How to add vibrations to an experiment

Hi There,

You can present vibrating in your task by adding a code component, change the “code Type” to JS and then adding this in the Begin Routine tab (if you do indeed want the vibration to happen at the start of the routine):

navigator.vibrate(1000);

where “1000” is the duration of the fibration in ms - for more details on what you can add into the navigator vibrate see here.

Note that this will not work on devices that do not have a vibrate feature available. So, to avoid an error, I suggest that you add the following to the Begin Experiment tab of your code component:

if ('vibrate' in navigator) {
    console.log('You browser supports vibrations');
} else {
    console.log('You browser does not supports');
    alert("Your browser does not support vibrations, which are important to this study. Please use an Anderoid device with a chrome or firefox browser");
}

Hope this helps!
Becca