EditText editText = findViewById(R.id.editText); editText.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View view, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) { // Perform action on enter key press return true; } return false; } });In this example, we set a key listener on an EditText widget and check for the enter key code. If the enter key is pressed and released, we perform a custom action and return true to indicate that we've handled the event. The android.widget package is part of the Android platform SDK and provides a collection of UI components for building Android apps.