[Techtalk] Detection of mouse-clicks and/or keypresses in Python

Cynthia Kiser cnk at ugcs.caltech.edu
Wed Jun 3 15:31:19 UTC 2015


Quoting David Sumbler <david at aeolia.co.uk>:
> I want to write a simple program in Python 3, for my own use, which will
> detect mouse-clicks (or possibly key-presses from the keyboard) and
> record the exact time of each event.
> 
> In principle this should be easy enough, except that I do not know how
> to detect the events themselves.
> 
> The only information I need to collect is the time of the event: for
> this particular program I am not interested in recording which button or
> key is pressed.
> 
> I have searched on the internet, but I can't seem to find what I want.
> What would be the simplest way to detect these events using Python?

My instinct is to say that you can't do that in just Python. Python
knows about stdin and stdout but not those new fangled mice. I think
you will need to use one of Python's GUI integrations like Tkinder or
something from https://wiki.python.org/moin/GuiProgramming



-- 
Cynthia N. Kiser
cnk at ugcs.caltech.edu


More information about the Techtalk mailing list