Code example for KeyEvent

Methods: getAction

0
        editText.setOnKeyListener(new View.OnKeyListener() {
 
            @Override 
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                // If the event is a key-down event on the "enter" button 
                if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                    runnable.run();
                    return true; 
                } 
                return false; 
            } 
        }); 
 
    } 
 
}