key press detection: which key?

i would like to detect every alphanumeric character. this code sets an event handler (onLetterPress) for each alpha character.

for n in range(0, 26):
  c = '%c' % (ord('a') + n)
  self.accept(c + '-up', self.onLetterPress)

but inside onLetterPress, how can i detect which key was pressed? something like ‘get last event’ which might hold the keyboard character?

there is one easy way to do.

First modify onLetterPress to accept one additionnal args like this:


then change your code to
self.accept(c + ‘-up’, self.onLetterPress,[c])

this way when Panda receive event c-up it will call onLetterPress with theKey=‘c’