Please post what you wind up using, this comes up for me pretty often too. In Windows there's a super easy way to get global keypresses, but I haven't found anything in *nix.Windows method:i = win32api.GetAsyncKeyState([keycode])On Thu, May 30, 2013 at 1:02 AM, winkleink <winkleink@xxxxxxxxx> wrote:
James - thank you. I will have a look at your code.I was getting the feeling that this is how Pygame works.Pygame will read a USB gamepad without any display.So, somehow a gamepad is different to a keyboard.Again, thank you for your help.Albert.On 30 May 2013 03:50, James Paige [via pygame-users] <[hidden email]> wrote:
A couple years ago I was trying to do something very similar. It wasn't
a raspbery pi, but it was a very small fanless linux box running debian.
In production, it had no monitor and never ran X. All the output was to
a serial LCD and all the input was from a barcode scanner that sent
keypresses as a keyboard.
I tried to use pygame for reading the input, but I finally gave up.
Without a window, pygame is just the wrong tool for the job.
I finally ended up using python's termios module. Here is a small
wrapper that I used http://pastebin.com/q9xMVUSb
I also found the timeout module handy in combination with reading raw
stdin, but whether or not it will be useful for your program I don't know.
---
James Paige
On Wed, May 29, 2013 at 05:05:59PM -0700, winkleink wrote:> Sent from the pygame-users mailing list archive at Nabble.com.
> Hi,
>
> I'm running pygame in a raspberry pi.
> The program I am writing has no graphical interface and I am connecting
> using SSH (Putty from a Windows XP computer)
>
> I want to capture a key press (with no graphical interface) and take action.
> Below is my code. From what I can tell it should work.
>
> Any advice greatly appreciated.
>
>
>
>
>
> --
> View this message in context: http://pygame-users.25799.x6.nabble.com/Using-Pygame-to-capture-key-presses-for-CLI-prgram-tp719.html
>
http://pygame-users.25799.x6.nabble.com/Using-Pygame-to-capture-key-presses-for-CLI-prgram-tp719p723.htmlIf you reply to this email, your message will be added to the discussion below:
View this message in context: Re: [pygame] Using Pygame to capture key presses for CLI prgram?