This property reports whether the computer is a touch device.
<computer>
computer.name.touch
Read Only
boolean
It returns 1 (=touchscreen detected) or 0 (= no touchscreen detected).
This property is useful in case instructions should be adapted for touchscreen use or to terminate scripts on non-touch screens that require touch input.
The following displays if the script is run on a touch device':
<text myText>
/ items= ("touch = <% computer.touch %>")
</text>
The following displays if the script is run on a touch device in an instruction page:
<page myPage>
touch = <% computer.touch %>
</page>
The following expression adapts some instruction text based on whether the script is run on a touchscreen.
<expressions>
/ instructText = {
if (computer.touch){
return "touch the button with your finger";
} else {
return "click the button with your mouse";
}
}
</expressions>
The following trial terminates a script if no touchscreen is detected at the end of the trial. Note that the termination trial is skipped for touchscreens.
<trial touchScreenCheck>
/ skip = {
return (computer.touch); //script only terminates if 'computer.touch' returns 0 (false)
}
/ stimulusFrames = [1 = goodbye]
/ timeout = 1000
/ onTrialEnd = {
script.abort();
}
</trial>