import pygamefrom pygamelocals import K_UP K_DOWN K_LEFT K_RIGHT K_ESCAPE KEYDOWN QUITpygameinitscreen = pygamedisplayset_mode800 600running = Truewhile running for event in p
The code you provided should allow you to close the pygame window by pressing the Esc key. If you are unable to close the pygame window with Esc, there could be a few possible reasons:
-
The code snippet you provided is not the complete code, and there may be other parts of your code interfering with the event handling.
-
There may be an issue with your pygame installation. Try reinstalling pygame or updating to the latest version.
-
It is possible that there is an issue with your keyboard or the key mapping. You can try using a different keyboard or checking if the Esc key is functioning properly.
If none of these solutions work, please provide more information about your code and any error messages you are receiving, so we can help you further.
原文地址: https://www.cveoy.top/t/topic/i9fX 著作权归作者所有。请勿转载和采集!