'If key is given, bind fun to key-press event of key.
Otherwise bind fun to any key-press.
Canvas must have focus. See method listen.'

def _onkeypress(self, fun, key=None):

    if (fun is None):
        if (key is None):
            self.cv.unbind('<KeyPress>', None)
        else:
            self.cv.unbind(('<KeyPress-%s>' % key), None)
    else:
        def eventfun(event):
            fun()
        if (key is None):
            self.cv.bind('<KeyPress>', eventfun)
        else:
            self.cv.bind(('<KeyPress-%s>' % key), eventfun)
