This property reports whether the computer has a hardware keyboard.
<computer>
computer.name.hasKeyboard
Read Only
boolean
Being able to detect whether the script can rely on an external keyboard is useful, for example, to adapt instructions or abort scripts if no keyboard is detected but a keyboard is deemed necessary for the functioning of the script.
The following displays whether we're on a computer with a hardware keyboard':
<text myText>
/ items= ("hasKeyboard = <% computer.hasKeyboard %>")
</text>
The following displays the current keyboard status in an instruction page:
<page myPage>
hasKeyboard = <% computer.hasKeyboard %>
</page>
The following trial demonstrates how the property 'hasKeyboard' can be used to terminate a script prematurely if no keyboard is found.
<trial keyboardCheckFail>
/ skip = {
return (computer.hasKeyboard); //trial is only run if NO keyboard is detected
}
/ stimulusFrames = [1 = keyboardFailAlert]
/ timeout = 2000
/ onTrialEnd = {
script.abort(); //the script is aborted at this point
}
</trial>