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 <winkle...@gmail.com> 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]<http://user/SendEmail.jtp?type=node&node=724&i=0>
> > 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:
>>
>> > 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
>> > Sent from the pygame-users mailing list archive at Nabble.com.
>> >
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the
>> discussion below:
>>
>> http://pygame-users.25799.x6.nabble.com/Using-Pygame-to-capture-key-presses-for-CLI-prgram-tp719p723.html
>>  To unsubscribe from Using Pygame to capture key presses for CLI prgram?, 
>> click
>> here.
>> NAML<http://pygame-users.25799.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
> ------------------------------
> View this message in context: Re: [pygame] Using Pygame to capture key
> presses for CLI 
> prgram?<http://pygame-users.25799.x6.nabble.com/Using-Pygame-to-capture-key-presses-for-CLI-prgram-tp719p724.html>
>
> Sent from the pygame-users mailing list 
> archive<http://pygame-users.25799.x6.nabble.com/>at Nabble.com.
>

Reply via email to