Capturing keystrokes in the background is something I've had a lot of problems with too. On Windows, the PyHook module works great for this, as does the win32api module. Something like:
      # keyboard c
      i = win32api.GetAsyncKeyState(67)
      if i < 0:
        print "pressed!"
That doesn't require focus.Â
I've never solved this riddle on other OS's though, and have resorted to using joystick buttons in Pygame, which always work in the background no matter the OS (and you can easily wire into most joystick buttons if you don't mind a little soldering).Â
If possible please post if you figure out how to capture keystrokes in the background through another method.