| Reference | Downloads | Github

Disable touch screen

Question: Is there a way to disable the touch screen? I’d like participants to use a mouse or trackpad for an online study.

Touchscreen mouse behaviour could be spotted with large jumps in the coordinates.

1 Like

coord_data.csv (1016.5 KB)
I think that would work if there were intermittent clicks, but I’m not sure about when the task involves drawing or tracing. In the attached data, some of the trials are touchscreen and some are mouse. If the touchscreen can’t be disabled, I would hope to figure out some way to discriminate between the trials. The touch also registers as a left mouse click, but perhaps there’s a way to detect a touchscreen response specifically?

Partial answer: you could listen for touchstart events, and warn the participant/stop the task if any are detected? e.g.

let canvas = ... // access the canvas somehow. Maybe `win._renderer.view`?
let cb = (evt) => { console.error("no touchscreens"); }
canvas.addEventListener("touchstart", cb, false)

Which seems like it could work in most situations (mobile devices & laptop with touchscreen properly detected), though it isn’t currently supported in Safari or Internet Explorer. More Touch API details here: Touch events - Web APIs | MDN

Unfortunately, I don’t have any good tips for how you could integrate this (probably a custom code component if this is in Builder?).

1 Like

Thanks aforren1, that’s a good idea to think about. I’m not quite sure how it might work either, and whether the touch listener would be able to discriminate between a trackpad and an actual touchscreen. I might try to look into this option, although it would be most convenient to figure out a way to do this regardless of browser type.

Warning: a work in progress

I’ve been toying with enabling multi-touch on touch screen devices for another project and have something that I hope might help you
run link:
files link: Pavlovia

Essentially you monitor for ongoing touch events in the way that @aforren1 describes. This is implemented by replacing the addMouseEventListeners in the core module I therefore import a custom psychojs library here. You can then check inside your experiment how many ongoing touches there are by checking the length of psychoJS.ongoingTouches. For your purposes, you would want to check this was 0, which would mean there were no current touch events.

This is still a work in progress so needs tweaks and improvements, but I hope that you find it helpful. Let me know if you have questions,

EDIT: I notice that the version I shared here might be an old version where the circle is always assigned the first touch event, for your purposes you only need to know nTouches, so this should be ok, but I’ll be updating the demo with the more recent update asap

1 Like

Thanks for this Becca, psychoJS.ongoingTouches in the custom library works like a charm.
To sum up, we can’t disable the touchscreen (which could still be a potentially convenient feature), but it seems likely that people are moving in the direction of more, rather than less touchscreen. A touch press is logged as a left mouse click, but psychoJS.ongoingTouches is unique to a touch screen (and not trackpad). I’m marking this as the solution.

1 Like

Summarized perfectly - can’t currently disable just monitor - pleased this helps!