Pygame - How can I allow my users to change their input keys? (Custom Keybinding)

后端 未结 2 946
名媛妹妹
名媛妹妹 2020-12-19 18:56

I\'m trying to make a game and want the user to change their input keys, e.g. they press the A key and that changes the MoveUp variable to the A key so that whe

2条回答
  •  眼角桃花
    2020-12-19 19:24

    When you get event KEYDOWN then you have pressed key in event.key

    while not Fin:
        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN
                MoveUp = event.key
    

    BTW: Every event may have different fields. You can see all on yellow list in documentation: event

提交回复
热议问题