psychopy.org | Reference | Downloads | Github

Is it possible to make Pavlovia experiment inaccessible on tablets and mobile devices?

Hi, I’ve been trying to make my project unable to be accessed via mobile phones and tablets and have hit a bit of a snag because it appears to still be running on my devices when I test it, has anyone had any luck doing this? Thanks!

This is interesting–I honestly never thought of participants using a phone/tablet… PsychoJS automatically records the device’s OS and puts it in your data output. They grab that info using window.navigator.platform; in their javascript code. Perhaps you can make a routine at the beginning of the experiment with a text component that says “phones/tablets not allowed, please exit the experiment” (or something) and set it to never end. Then you could make a js only code component in that routine that creates a variable os = window.navigator.platform; and make an if/then statement that only ends that routine (continueRoutine = false;) if the OS is windows or mac. So it will only show that text if they don’t have a computer OS and they can’t move on–only escape to leave the experiment. If the OS code doesn’t work, you could do the same thing with screen size (window.screen.width; & window.screen.height;) and say only screens that are larger than x can move on from that screen. I might try to start doing this as well.

Fortunately, there is code that already does this on Wakefield Morys-Carter’s Cribsheet: PsychoPy Python to Javascript crib sheet 2021 - Google Docs

This is the code, just pop it in the begin experiment section of a javascript only code component:

// Automatically exit if the experiment is running on a mobile device
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
  quitPsychoJS('Mobile device detected. Goodbye!', false)
}

1 Like

Press space to continue with a keyboard component will stop mobile device users in their tracks.

I think that this partially accounts for the high drop out rate in most PsychoPy experiments.

1 Like

I did NOT know this and was going to suggest something wild about detecting touches - great tip Wake and Tim!