Python: onkeypress without turtle window?
Question: My problem at this time is, that I want to detect a keypress through the
command

    
    
    onkeypress(fun,"key")
    

but when I import onkeypress and listen from turtle, a turtle window pops out,
when I run my program. Do you know how to close it again, or how to not even
let it appear? Thanks for hopefully coming answers, sorry for my bad english
(I'm german and 13)


Answer: It might be hard to find experts in python
[turtle](https://docs.python.org/3/library/turtle.html). However, if you are
not limited to that library, you may use the following code to get the key
pressed by the user (last call actually gets the key for you):

    
    
    class _Getch:
        """Gets a single character from standard input.  Does not echo to the
    screen."""
        def __init__(self):
            try:
                self.impl = _GetchWindows()
            except ImportError:
                self.impl = _GetchUnix()
    
        def __call__(self): return self.impl()
    
    
    class _GetchUnix:
        def __init__(self):
           import tty, sys
    
        def __call__(self):
            import sys, tty, termios
            fd = sys.stdin.fileno()
            old_settings = termios.tcgetattr(fd)
            try:
                tty.setraw(sys.stdin.fileno())
                ch = sys.stdin.read(1)
            finally:
                termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
            return ch
    
    
    class _GetchWindows:
        def __init__(self):
            import msvcrt
    
        def __call__(self):
            import msvcrt
            return msvcrt.getch()
    
    
    getch = _Getch()
    

Code comes from [this article](http://code.activestate.com/recipes/134892/)

