LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: mireazma on April 05, 2014, 17:31:07

Title: force Display.isCloseRequested()
Post by: mireazma on April 05, 2014, 17:31:07
I want to assign `esc`key to close the application. I have while(! Display.isCloseRequested()) which I want to end.
Title: Re: force Display.isCloseRequested()
Post by: quew8 on April 07, 2014, 19:54:59
So create a boolean variable, "remainOpen" or whatever, initialized to true. Test this variable in your while loop. Then, in the game loop, check for the escape key being pressed (this link describes how to test for key presses: http://lwjgl.org/wiki/index.php?title=LWJGL_Basics_2_(Input)#The_Event_Buffer (http://lwjgl.org/wiki/index.php?title=LWJGL_Basics_2_(Input)#The_Event_Buffer)) and if it is, set the remainOpen variable to false. Then at the end of the current iteration the loop will end.