Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

# KeyboardView.OnKeyboardActionListener

*** ** * ** ***

` public static interface KeyboardView.OnKeyboardActionListener `   
` `

|---|
| android.inputmethodservice.KeyboardView.OnKeyboardActionListener |

<br />

*** ** * ** ***

Listener for virtual keyboard events.

## Summary

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#onKey(int,%20int[])(int primaryCode, int[] keyCodes) ` Send a key press to the listener. |
| ` abstract void` | ` https://developer.android.com/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#onPress(int)(int primaryCode) ` Called when the user presses a key. |
| ` abstract void` | ` https://developer.android.com/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#onRelease(int)(int primaryCode) ` Called when the user releases a key. |
| ` abstract void` | ` https://developer.android.com/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#onText(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence text) ` Sends a sequence of characters to the listener. |
| ` abstract void` | ` https://developer.android.com/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#swipeDown()() ` Called when the user quickly moves the finger from up to down. |
| ` abstract void` | ` https://developer.android.com/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#swipeLeft()() ` Called when the user quickly moves the finger from right to left. |
| ` abstract void` | ` https://developer.android.com/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#swipeRight()() ` Called when the user quickly moves the finger from left to right. |
| ` abstract void` | ` https://developer.android.com/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#swipeUp()() ` Called when the user quickly moves the finger from down to up. |

## Public methods

### onKey

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onKey (int primaryCode, 
                int[] keyCodes)
```

Send a key press to the listener.

<br />

| Parameters ||
|---|---|
| `primaryCode` | `int`: this is the key that was pressed <br /> |
| `keyCodes` | `int`: the codes for all the possible alternative keys with the primary code being the first. If the primary key code is a single character such as an alphabet or number or symbol, the alternatives will include other characters that may be on the same key or adjacent keys. These codes are useful to correct for accidental presses of a key adjacent to the intended key. <br /> |

### onPress

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onPress (int primaryCode)
```

Called when the user presses a key. This is sent before the `https://developer.android.com/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#onKey(int,%20int[])` is called. For keys that repeat, this is only called once.

<br />

| Parameters ||
|---|---|
| `primaryCode` | `int`: the unicode of the key being pressed. If the touch is not on a valid key, the value will be zero. <br /> |

### onRelease

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onRelease (int primaryCode)
```

Called when the user releases a key. This is sent after the `https://developer.android.com/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#onKey(int,%20int[])` is called. For keys that repeat, this is only called once.

<br />

| Parameters ||
|---|---|
| `primaryCode` | `int`: the code of the key that was released <br /> |

### onText

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onText (CharSequence text)
```

Sends a sequence of characters to the listener.

<br />

| Parameters ||
|---|---|
| `text` | `CharSequence`: the sequence of characters to be displayed. <br /> |

### swipeDown

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void swipeDown ()
```

Called when the user quickly moves the finger from up to down.

<br />

### swipeLeft

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void swipeLeft ()
```

Called when the user quickly moves the finger from right to left.

<br />

### swipeRight

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void swipeRight ()
```

Called when the user quickly moves the finger from left to right.

<br />

### swipeUp

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void swipeUp ()
```

Called when the user quickly moves the finger from down to up.

<br />