'telegraphy' as a means of data entry

Peter Hansen peter at engcorp.com
Sun Sep 12 09:20:19 EDT 2004


Elaine Jackson wrote:

> "Peter Hansen" <peter at engcorp.com> wrote:
> | Elaine Jackson wrote:
> |
> | > I need to record the respective times of the events in a sequence of
> | > presses/releases of a particular key on the computer keyboard. 
> |
> | Does this have to work regardless of what else is going on on
> | the computer, or is it okay if it works only when the window
> | for this particular application is active?  
> 
> Just when the window is active.

Then the relevant bits in wxPython would involve lines like these
lines, pruned from a little app I've been working on:

class Frame(wx.Frame):
     def __init__(self, title):
         wx.Frame.__init__(self, None, -1, title)
         p = wx.Panel(self, -1)

         self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
         # self.Bind(wx.EVT_KEY_DOWN, self.OnKeyUp)


     def OnKeyDown(self, evt):
         if evt.GetKeyCode() == wx.WXK_DELETE:
             # whatever


You would be able to use time.time() or time.clock() to record
the times of the keypresses, and I don't generally work with
audio so I don't know what would be best.

An alternative would be Pygame, http://www.pygame.org/, which
certainly could handle both the key stuff and the audio.

And Tkinter could certainly do it to, but I don't do Tkinter. :)

-Peter



More information about the Python-list mailing list