0

Can I assign the Exit Command to the # key in an Lwuit Application? When I press the key #, the Exit command should be called automatically and exit the application.

Shankar
  • 31
  • 8

1 Answers1

4

You should listen for a KeyPress or keyReleased event on the form with the keycode for # and exitApplication when the # key is pressed.

protected void keyPressed(int key)
{
    System.out.println("Key Pressed");

    if(key==52) //change 52 to match keyCode for # key 
    {
      Display.getInstance().exitApplication();
    }
}
Ajibola
  • 1,218
  • 16
  • 28
  • What do you mean by calling a command like open, close? You can execute any code you want after getting the keyPressed/keyReleased event in the code braces {}. – Ajibola Jan 14 '12 at 01:12