Exiting a MultiPoint Mouse Application

When you start your MultiPoint Mouse-enabled application, a pointer appears on the screen for each mouse device that is connected to the computer. It might be difficult to exit the application because the mouse devices cannot click standard controls, such as the Close button in the upper-right corner of a screen. You should add a keyboard event handler that can be used to exit the application when a certain key (for example, the ESC key) is pressed. Do this by adding a KeyEventHandler declaration in the constructor for the main application window, as follows:

// Declare KeyEventHandler to handle keyboard events 
this.KeyDown += KeyDown_Event;

After adding the KeyEventHandler declaration, create an event handler as follows:

// Handle keyboard events
private void KeyDown_Event(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Escape)
    {
        MultipointSdk.Instance.Dispose();
        App.Current.Shutdown();
    }
}