Two input methods that rely on keyboard processing OS
import sys for line in sys.stdin.readlines(): print line
This is one โsimpleโ solution to your problem, given that it reads the sys.stdin file, you will probably need a driver, and if the OS blocks the material along the way, it will probably break anyway.
This is another solution (linux afaik only):
import sys, select, tty, termios class NonBlockingConsole(object): def __enter__(self): self.old_settings = termios.tcgetattr(sys.stdin) tty.setcbreak(sys.stdin.fileno()) return self def __exit__(self, type, value, traceback): termios.tcsetattr(sys.stdin, termios.TCSADRAIN, self.old_settings) def get_data(self): try: if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []): return sys.stdin.read(1) except: return '[CTRL-C]' return False data = '' printed = '' last = '' with NonBlockingConsole() as nbc: while 1: c = nbc.get_data() if c: if c == '\x1b':
Is there a problem with the driver?
If none of the above work, you will not be able to get the keys in Python.
Most likely, you will need an actual driver that can analyze data sent from the keyboard, which is not a normal keyboard event in the USB stack, that is ... This is a low-level control method for Python, and you're out of luck ... if you don't know how to create linux drivers.
Anyway, take a look: http://ubuntuforums.org/showthread.php?t=1490385
It seems like more people were trying to do something.
PyUSB Attempt
http://pyusb.sourceforge.net/docs/1.0/tutorial.html
You can try the PyUSB solution and extract the raw data from the USB jack, but again. If the G-keys are not registered as โtraditionalโ USB data, they can be reset and you will not receive it.
Connecting to Input Channels on Linux
Another untested method, but may work // Hackaday: 