Python:按住键不';我不能在mac上工作

Python:按住键不';我不能在mac上工作,python,macos,python-2.7,tkinter,keypress,Python,Macos,Python 2.7,Tkinter,Keypress,所以我有一个小python游戏,你有一个球,你可以用箭头键移动。我的代码在运行Python 3.5.1的Windows上运行良好,但在运行Python 2.7.10的Mac上不起作用。当您按住向右箭头时,它似乎会不断触发按键和按键释放,而不是像在Windows中那样不断调用按键。这是一个问题,因为在我的keyrease方法中,它会停止KeyPress中发生的导致启动和停止运动的动作 那么,我如何让Mac识别出钥匙被按下,这样它就不会一直调用keyrease 相关代码 def add_b

所以我有一个小python游戏,你有一个球,你可以用箭头键移动。我的代码在运行Python 3.5.1的Windows上运行良好,但在运行Python 2.7.10的Mac上不起作用。当您按住向右箭头时,它似乎会不断触发
按键
按键释放
,而不是像在Windows中那样不断调用
按键
。这是一个问题,因为在我的
keyrease
方法中,它会停止
KeyPress
中发生的导致启动和停止运动的动作

那么,我如何让Mac识别出钥匙被按下,这样它就不会一直调用
keyrease

相关代码


    def add_bindings(self):
        self.canvas.bind("", self.right_press)
        self.canvas.bind("", self.left_press)
        self.canvas.bind("", self.right_release)
        self.canvas.bind("", self.left_release)

    #key presses
    def right_press(self, e):
        self.ball.change_right(True)
    def right_release(self, e):
        self.ball.change_right(False)
    def left_press(self, e):
        self.ball.change_left(True)
    def left_release(self, e):
        self.ball.change_left(False)

self.canvas.bind(“,self.right\u press)的作用是什么?为什么要使用内置的python和Tkinter for mac?什么是
self.canvas.bind(“,self.right\u press)
?为什么要使用内置的python和Tkinter for mac?