[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:


//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() {

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;
} else if (name.equals("profiler") && !isPressed) {
profiler = !profiler;

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:



…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