Skip to content

Commit

Permalink
update code for keyboard and mouse inputs for PsychoPy5
Browse files Browse the repository at this point in the history
  • Loading branch information
hejibo committed Oct 21, 2016
1 parent 51d4050 commit 9950a3a
Show file tree
Hide file tree
Showing 177 changed files with 36 additions and 11 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,52 @@
- show text

~~~~{python}
CapturedResponseString = visual.TextStim(myWin,
units='norm',height = 0.2,
pos=(0,-0.40), text='',
alignHoriz = 'center',alignVert='center', color=[-1,-1,-1])
textString = "Press any key to continue\n"
message = visual.TextStim(win, text=textString)
captured_string = '' #key presses will be captured in this string
~~~~

!SLIDE left

# Capture Keyboard Inputs
- event.waitKeys()

~~~~{python}
event.waitKeys()
~~~~

!SLIDE left

# Capture Keyboard Inputs

~~~~{python}
CapturedResponseString = visual.TextStim(myWin,
units='norm',height = 0.2,
pos=(0,-0.40), text='',
alignHoriz = 'center',alignVert='center', color=[-1,-1,-1])
#key presses will be captured in this string
CapturedResponseString.text = event.waitKeys()[0]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# There is little experiment if the experimentee cannot give any input.
# Here we changed our assignmet 1 a bit so that it waits for a keys, rather
# than waiting 5 s. Note that we need to import the event library from
# PsychoPy to make this work.
from psychopy import core, visual, event
## Setup Section
win = visual.Window([400,300], monitor="testMonitor")
textString = "Press any key to continue\n"
message = visual.TextStim(win, text=textString)
## Experiment Section
message.draw()
win.flip()
c = event.waitKeys() # read a character
message = visual.TextStim(win, text=textString + c[0])
message.draw()
win.flip()
event.waitKeys()
## Closing Section
win.close()
core.quit()
~~~~


Expand Down
Binary file added Lecture 5. Loops & Iterations/.DS_Store
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file added References for PsychoPy/.DS_Store
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file removed example code for Lecture 5. Loops & Iterations.zip
Binary file not shown.

0 comments on commit 9950a3a

Please sign in to comment.