We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › ESC key code is used only for exitting a program!
Page Index Toggle Pages: 1
ESC key code is used only for exitting a program! (Read 2153 times)
ESC key code is used only for exitting a program!
Jun 10th, 2010, 1:31pm
 
how can i use ESC key not to exit a program but to lets say change state of a game to paused or something else???
Re: ESC key code is used only for exitting a program!
Reply #1 - Jun 10th, 2010, 3:00pm
 
Lord_Sonic wrote on Jun 10th, 2010, 1:31pm:
how can i use ESC key not to exit a program but to lets say change state of a game to paused or something else?


I'm new to this, so don't blame me if I'm wrong, but I think this should work:

if (keyPressed) {
     if (key == 27) { //The ASCII code for esc is 27, so therefore: 27
     //insert your function here
     }
}
Re: ESC key code is used only for exitting a program!
Reply #2 - Jun 10th, 2010, 3:03pm
 
almost!  the key part is this:

if (key == ESC) key=0; // trap ESC so it doesn't quit

otherwise the ESC/27 code will pass on.
Re: ESC key code is used only for exitting a program!
Reply #3 - Jun 10th, 2010, 3:44pm
 
thank you ben hemme!! thank you both! THE GAME IS COMPLETE! i am presenting it next thursday here in greece!
Page Index Toggle Pages: 1