[Input] Special treating of ESC key?

I’ve added to my main app mapping for ESC (escape) key with listener directing it to main menu, but for some reason, game still exits after pressing ESC, even though I have listener that should block it.



I want my game to go to main menu upon pressing ESC, not quit.



My code:

[java]

//In simpleInitApp

inputManager.addMapping(“profiler”, new KeyTrigger(KeyInput.KEY_F3));

inputManager.addMapping(“FPS”, new KeyTrigger(KeyInput.KEY_F4));

inputManager.addMapping(“MainMenu”, new KeyTrigger(KeyInput.KEY_ESCAPE));

inputManager.addListener(Global, “profiler”,“FPS”,“MainMenu”);

//



//Listener "Global":
ActionListener Global = new ActionListener() {

@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("profiler") && !isPressed) {
profiler = !profiler;
UpdateSettings(); // update settings is function that updates visibility
//of fps counter and profiler at same time, so I don't have to have same code in different places
} else if (name.equals("FPS") && !isPressed) {
fpsCounter = !fpsCounter;
UpdateSettings();
} else if (name.equals("profiler") && !isPressed) {
profiler = !profiler;
UpdateSettings();
}
}
};[/java]

It’s funny… when I went up to the google search box up in the corner up there (upper right) and put in “application escape exit” I get a few relevant links:

http://hub.jmonkeyengine.org/groups/general-2/forum/topic/disabling-exit-when-esc-key-triggered/

http://hub.jmonkeyengine.org/groups/general-2/forum/topic/removing-esc-key-to-exit

…and probably more…



The second one actually leads to an answer if you scroll down far enough.

@pspeed said:
It's funny... when I went up to the google search box up in the corner up there (upper right) and put in "application escape exit" I get a few relevant links:
...

Yes @DariuszG.Jagielski, please use the search a little more.

I think its even a FAQ item. Really, keep it down and do your research. Another short post like this without any links or content that proves you researched on the topic on your own and the thread will just be closed.

1 Like