Sunday, August 3, 2008

How do I check whether a particular key has been pressed?

# initialize your ButtonChooser
pressed, rt = waitWithChoice(blah,blah)

if pressed==None:
  print 'You did not press a key'
else:
  if pressed==Key('a'):
    print 'You pressed the A key'
  else:
    print 'You pressed something other than the A key'

No comments: