# on_key_down(key)
键盘按键按下时调用,key
为当前按键。
from cpgzero import *
alien = Actor("alien")
def on_key_down(key):
if key == keys.LEFT:
alien.x -= 10
elif key == keys.RIGHT:
alien.x += 10
elif key == keys.SPACE:
alien.angle += 5
← mouse on_key_up(key) →