public boolean onKey(KeyEvent event) {
        if (!isInitialized()) {
            return false;
        }

        TouchEvent evt;
        // TODO: get touch event from pool
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            evt = new TouchEvent();
            evt.set(TouchEvent.Type.KEY_DOWN);
            evt.setKeyCode(event.getKeyCode());
            evt.setCharacters(event.getCharacters());
            evt.setTime(event.getEventTime());

            // Send the event
            addEvent(evt);

        } else if (event.getAction() == KeyEvent.ACTION_UP) {
            evt = new TouchEvent();
            evt.set(TouchEvent.Type.KEY_UP);
            evt.setKeyCode(event.getKeyCode());
            evt.setCharacters(event.getCharacters());
            evt.setTime(event.getEventTime());

            // Send the event
            addEvent(evt);

        }

        if (isSimulateKeyboard()) {
            KeyInputEvent kie;
            char unicodeChar = (char)event.getUnicodeChar();
            int jmeKeyCode = AndroidKeyMapping.getJmeKey(event.getKeyCode());

            boolean pressed = event.getAction() == KeyEvent.ACTION_DOWN;
            boolean repeating = pressed && event.getRepeatCount() > 0;

            kie = new KeyInputEvent(jmeKeyCode, unicodeChar, pressed, repeating);
            kie.setTime(event.getEventTime());
            addEvent(kie);
//            logger.log(Level.FINE, "onKey keyCode: {0}, jmeKeyCode: {1}, pressed: {2}, repeating: {3}",
//                    new Object[]{event.getKeyCode(), jmeKeyCode, pressed, repeating});
//            logger.log(Level.FINE, "creating KeyInputEvent: {0}", kie);
        }

        // Consume all keys ourselves except Volume Up/Down and Menu.
        //   Don't do Menu so that typical Android Menus can be created and used
        //   by the user in MainActivity.
        if ((event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) ||
                (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) ||
                (event.getKeyCode() == KeyEvent.KEYCODE_MENU)) {
            return false;
        } else {
            return true;
        }

   }
AndroidTouchInput is the base class that receives touch inputs from the
Android system and creates the TouchEvents for jME.  This class is designed
to handle the base touch events for Android rev 9 (Android 2.3).  This is
extended by other classes to add features that were introduced after
Android rev 9.

@author iwgeric
jme3-android/src/main/java/com/jme3/input/android/AndroidTouchInput.java