I am creating an app which provides chat functionality in it. There is an EditText in the screen, on which I have set OnKeyListener. Whenever user presses the "Enter" key after typing the message, the message is posted on the screen. It works fine. Here is my EditText:
<EditText android:id="@+id/chatMessageField"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_marginRight="5dip" android:layout_marginLeft="5dip"
android:maxLines="2" android:minLines="1" android:scrollbars="vertical"
android:hint="@string/chatMessageHintText" android:textColorHint="#3b64a8">
</EditText>
The problem is when user wants to go to new line before the EditText wraps the text and goes to new line. Now if user wants to go to new line and presses "Enter" key, the message is sent.
In some chat messangers , I have seen that pressing "Shift+Enter"(or any other key-combination) simultaneously takes the user to new line. How can we detect "Shift+Enter"(or any other key-combination) keys pressed simultaneously in Android? Is there any way to achieve this functionality in Android?