Search code examples
androidandroid-keypad

Events of Android AVD Emulator keyboard


How to get the key events of the AVD emulator keyboard in my application I want to move my Sprite i.e Character based on arrow keys in keyboard of android emulator ?

Say Per one click on arrow keys of android emulator I want to move my Sprite 1.0f distance

and on enter key I want to show some animation ...

how should I go about it ?


Solution

  • Try this:-

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // TODO Auto-generated method stub
        if(keyCode==KeyEvent.KEYCODE_BACK){
    
        } else if(keyCode==KeyEvent.KEYCODE_ENTER){
    
        }
        return super.onKeyDown(keyCode, event);
    }