I played around a bit with various things and found that the code below works:
myEditText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
// Do some stuff
}
});