Package psychopy :: Module event
[frames] | no frames]

Module event

source code

To handle from keyboard, mouse and joystick (joysticks require pygame to be installed). See demo_mouse.py and i{demo_joystick.py} for examples
Classes
  Mouse
Easy way to track what your mouse is doing.
Functions
 
getKeys(keyList=None, timeStamped=False)
Returns a list of keys that were pressed.
source code
 
waitKeys(maxWait=None, keyList=None)
Halts everything (including drawing) while awaiting input from keyboard.
source code
 
clearEvents(eventType=None)
Clears all events currently in the event buffer.
source code
Variables
  havePygame = True
  havePyglet = True
  mouseButtons = [0, 0, 0]
  mouseWheelRel = array([ 0., 0.])
  usePygame = True
Function Details

getKeys(keyList=None, timeStamped=False)

source code 
Returns a list of keys that were pressed.
Parameters:
  • keyList (None or []) - Allows the user to specify a set of keys to check for. Only keypresses from this set of keys will be removed from the keyboard buffer. If the keyList is None all keys will be checked and the key buffer will be cleared completely. NB, pygame doesn't return timestamps (they are always 0)
  • timeStamped (False or True or Clock) - If True will return a list of tuples instead of a list of keynames. Each tuple has (keyname, time). If a core.Clock is given then the time will be relative to the Clock's last reset

Author:

  • 2003 written by Jon Peirce
  • 2009 keyList functionality added by Gary Strangman
  • 2009 timeStamped code provided by Dave Britton

waitKeys(maxWait=None, keyList=None)

source code 

Halts everything (including drawing) while awaiting input from keyboard. Then returns list of keys pressed. Implicitly clears keyboard, so any preceding keypresses will be lost.

Optional arguments specify maximum wait period and which keys to wait for.

Returns None if times out.

clearEvents(eventType=None)

source code 
Clears all events currently in the event buffer. Optional argument, eventType, specifies only certain types to be cleared
Parameters:
  • eventType (None, 'mouse', 'joystick', 'keyboard') - If this is not None then only events of the given type are cleared