Touch Screen press modification

Hi everyone,
I am here posting to discuss how I modified my experiment to respond to a single tap from a touch screen. Originally I had an issue where the experiment I was working on required a user to double tap a screen or to tap and hold the screen for the experiment to register the response. This was not ideal and the result was a forced effort to get the system to register a response.

What I learned was that I could solve this using the code module in the builder. With the advice from Rebecca Hirst I was able to implement a hover method that resulted in the desired functionality. At the beginning of the routine a set of if statements are checked to see if the “mouse” (user’s cursor of where they will tap) is within one of the given images/shapes. If so the response is measured and the experiment continues.

Within the code module I added the following functionality.

At Begin Routine
I reset the cursor’s position with the setPos() function.

At Each Frame
I setup the if statements responsible for handling a press or “hover”.

if CorrectTarget.contains(Mouse/Curosr):
Set Correct response text
Set Correct response message
Set Correct response audio
ContinueRoutine = False

if IncorrectTarget.contains(Mouse/Curosr):
Set Incorrect response text
Set Incorrect response message
Set Incorrect response audio
ContinueRoutine = False

With the following implementation I was able to achieve the functionality for my experiment. Users can make an effortless single tap and the experiment will record the response appropriately.

1 Like

Offline I can see that touchscreens can be dealt with much more easily. Online, you can’t set the mouse position, hence my code to check for a change in location.

So the reason I used setPos() is because I require a hard reset for the cursor. My users will not have access to a mouse and I do not want the cursor to remain in the same position as the previous routine. I do not simply want to check for a change in the cursor’s position but I want to check if the cursors are in specified spaces and which specified space the cursor is in.

Thank you for the suggestion however it is not needed for my situation.