Keypress Input

Michael Torrie torriem at gmail.com
Tue Jun 16 13:15:58 EDT 2015


On 06/14/2015 11:23 PM, John McKenzie wrote:
>  Thank to the others who joined in and posted replies.
> 
>  Michael, your assumption is correct. To quote my original post, "and I 
> want this working on a Raspberry Pi." Doing a superficial look at curses 
> and getch it looks excessively complicated. I was under the impression it 
> was not multi-platform and Linux was excluded. Searching for getch and 
> raspberry pi on the web I see it is not and is available for Raspian.
> 
>  Worried about implementing it but I will consider it again. May spend 
> time reading about during my treatment tomorrow as the hospital has wifi 
> and Internet access and I am allowed to have my laptop there.

I'm not sure exactly what you mean by not available on Linux.  Curses
provides the same API on all platforms it runs on and I know it can read
keystrokes.  Curses getch is certainly available on Linux.  In fact,
here's an example:

http://stackoverflow.com/questions/10693256/how-to-accept-keypress-in-command-line-python

Again, however, you probably can't just fire up your program from a
startup script and have it run automatically, since stdin for a script
is not going to be the tty.  One idea would be to run your program from
init as a getty on tty1 (the default tty).  That would run as soon as it
boots up.

Though question for you. Why are you hooking the arcade buttons up to a
kade USB device?  Would not it be far simpler to hook the buttons
directly to a GPIO pin and read them from python?  You're already using
GPIO pins to run the LEDs.  Seems like the usb keyboard hack is
unnecessary and it's making your task more difficult.




More information about the Python-list mailing list