Holding a response button down

Ben Robinson BRobinso at mprc.umaryland.edu
Tue Jun 19 17:18:17 UTC 2007


i had to do something similar recently.

here's how i did it:

Dim nPresses as Long 'put this first line in the User section of your Script window

have a List object (List1) with a single row, weight=1, for your procedure.
the first object in the timeline of your procedure should be a Label object (Label1).
then put a slide object (Slide1) to display the horizontal line, and the cursor.  fill in the cursor's x-axis position as [xPos], or something like that, and add a column to your list called xPos.
then put an inline object following Slide1.  this code will check to see what the response to the Slide1 was, go back to Label1 if the response was to move the cursor either left or right, or exit the procedural loop if the response was {ENTER}, meaning the cursor is in the desired location.  if either {LEFTARROW} or {RIGHTARROW} is pressed, the inline will adjust the value of xPos in List1 so that the next time Slide1 is drawn the cursor's position will increment appropriately. 

here's the inline code:

nPresses = Keyboard.History.Count
Set lastPress = Keyboard.History(nPresses)

If lastPress Is Nothing Then
	Goto Label1
ElseIf Not lastPress Is Nothing Then
	Select Case lastPress.RESP
		Case "{LEFTARROW}"
			If xPos > [the farthest left the cursor can go on the line] Then
				xPos = xPos -1
			End If
			Goto Label1
		Case "{RIGHTARROW}"
			If xPos < [the farthest right the cursor can go on the line] Then
				xPos = xPos +1
			End If
			Goto Label1
		Case "{ENTER}" 'if they press {ENTER} don't return to Label1, thereby ending this loop.
		Case Else
			Goto Label1
	End Select
End If


>>> "Jared G. Smith" <jared.smith at reading.ac.uk> 6/19/2007 11:47 AM >>>
Hi

I am creating a line bisection task using a method of adjustment whereby 
participants are required to move (left or right) a vertical cursor 
superimposed on a horizontal line towards the perceived midpoint (the 
scripting for this resembles that of visual analogue scales).
Because in many trials the cursor begins placed some distance from the 
objective midpoint, rather than always having to press the response 
button to move the stimulus by one increment, I would like the user to 
be able to hold a keyboard button down in order to move the cursor in 
continuous increments (which would cease moving when the key was 
released) - rather like the effect of pressing a key down on a word 
processor. Does anyone know how such response movement could be achived?

Alternatively, does anyone have an example script for recording the 
duration of a button keyboard press response as I think I could use this 
duration to achieve continuous cursor movement in response to holding 
down a response button?

Would appreciate any help here. Thanks very much.

Best wishes

Jared G Smith

Research Fellow
School of Psychology and Clinical Language Sciences
University of Reading
Reading RG6 6AL
UK



More information about the Eprime mailing list