AWT/Swing

distinguish both return-/enter-keys

Both return-/enter-keys deliver the KeyCode VK_ENTER (10). The distinction is only possible on the basis of the position:


if (e.getKeyCode() == KeyEvent.VK_ENTER) {
   if(e.getKeyLocation() == KeyEvent.KEY_LOCATION_STANDARD) 
      System.out.println("Return");
   else
     if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_NUMPAD) 
        System.out.println("Enter");
}

Eigene Werkzeuge
Werkzeuge

gratis Counter by GOWEB
seit 9.10.2007