Quit with Escape

Been searching for the betterpart of an hour. I have a very simple program that I want to have the user quit from with the Escape key. How do I do that please?

//==============================================================================
class StartWindow : public Component
{
public:
//==============================================================================
StartWindow()
: Component (T(“AV”))
{
setOpaque (true);
setVisible (true);
addToDesktop (ComponentPeer::windowAppearsOnTaskbar | ComponentPeer::windowHasDropShadow);
centreWithSize (640, 480);
}

~StartWindow()
{
}

Thanks,
r.b.

Well if you’re just using a plain component, you’ll need to override keyPressed() to catch the escape key, and make it call JUCEApplication::quit(). But there are many other ways of doing it, too.

Not sure how to do that, hence the request for some specific code.

Thanks,
r.b

Not looking at Juce code right now, but it is something like this (symbols are probobly wrong as well as return type or whatnot, the manual can fill that in):

// add this method to your component subclass (remember, this is pseudo-code, fix the names with the proper ones) bool keyPressed(KeyEvent &K) { if(k.keytype==Key_Escape) } JuceApplication::quit(); // Send a quit message return true; // handled if the return type is indeed bool } return false; // not handled, pass through }

Should be something like that. I’ve been programming with three different input systems recently and this is probably a wierd conflaguration of all, but it should be like this in Juce.