from psychopy import visual, eventwin = visual.Window()mouse = event.Mouse()
def waitPressed(maxWait=float('inf'), keyList=(0,1,2), timeStamped=False): """ Equivalent to event.waitKeys but for the mouse's left-scroll-right buttons.
Returns the button_index if timeStamped=False (e.g. 2 for left key) Returns (button_index, duration) if timeStamped=True (e.g. (0, 4.343 for slow right key). Returns None if maxWait is exceeded. maxWait is infinite by default. """ mouse.clickReset() while True: if not mouse.mouseClock.getTime() >= maxWait: # if we're still within the maxWait duration buttons, times = mouse.getPressed(getTime=True) # get mouse presses for key in keyList: # match presses with keyList if buttons[key]: # Return in the desired format if timeStamped: return buttons.index(1), times[buttons.index(1)] else: return buttons.index(1) # Return None when maxWait is exceeded else: return None
# Try it outprint waitPressed(3, keyList=[1], timeStamped=True)
--
You received this message because you are subscribed to the Google Groups "psychopy-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- Jon Peirce http://www.peirce.org.uk
--
You received this message because you are subscribed to the Google Groups "psychopy-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- Jonathan Peirce University of Nottingham http://www.peirce.org.uk
This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.
--
You received this message because you are subscribed to the Google Groups "psychopy-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- Jonathan Peirce Nottingham Visual Neuroscience http://www.peirce.org.uk