Stay organized with collections
Save and categorize content based on your preferences.
KeyboardView.OnKeyboardActionListener
public
static
interface
KeyboardView.OnKeyboardActionListener
android.inputmethodservice.KeyboardView.OnKeyboardActionListener
|
Listener for virtual keyboard events.
Summary
Public methods |
abstract
void
|
onKey(int primaryCode, int[] keyCodes)
Send a key press to the listener.
|
abstract
void
|
onPress(int primaryCode)
Called when the user presses a key.
|
abstract
void
|
onRelease(int primaryCode)
Called when the user releases a key.
|
abstract
void
|
onText(CharSequence text)
Sends a sequence of characters to the listener.
|
abstract
void
|
swipeDown()
Called when the user quickly moves the finger from up to down.
|
abstract
void
|
swipeLeft()
Called when the user quickly moves the finger from right to left.
|
abstract
void
|
swipeRight()
Called when the user quickly moves the finger from left to right.
|
abstract
void
|
swipeUp()
Called when the user quickly moves the finger from down to up.
|
Public methods
onKey
public abstract void onKey (int primaryCode,
int[] keyCodes)
Send a key press to the listener.
Parameters |
primaryCode |
int : this is the key that was pressed |
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. |
onPress
public abstract void onPress (int primaryCode)
Called when the user presses a key. This is sent before the onKey(int, int)
is called.
For keys that repeat, this is only called once.
Parameters |
primaryCode |
int : the unicode of the key being pressed. If the touch is not on a valid
key, the value will be zero. |
onRelease
public abstract void onRelease (int primaryCode)
Called when the user releases a key. This is sent after the onKey(int, int)
is called.
For keys that repeat, this is only called once.
Parameters |
primaryCode |
int : the code of the key that was released |
onText
public abstract void onText (CharSequence text)
Sends a sequence of characters to the listener.
Parameters |
text |
CharSequence : the sequence of characters to be displayed. |
swipeDown
public abstract void swipeDown ()
Called when the user quickly moves the finger from up to down.
swipeLeft
public abstract void swipeLeft ()
Called when the user quickly moves the finger from right to left.
swipeRight
public abstract void swipeRight ()
Called when the user quickly moves the finger from left to right.
swipeUp
public abstract void swipeUp ()
Called when the user quickly moves the finger from down to up.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# KeyboardView.OnKeyboardActionListener\n\nAdded in [API level 3](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nDeprecated in [API level\n29](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nKeyboardView.OnKeyboardActionListener\n=====================================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/inputmethodservice/KeyboardView.OnKeyboardActionListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nKeyboardView.OnKeyboardActionListener\n`\n\n\n`\n\n\n`\n\n|------------------------------------------------------------------|\n| android.inputmethodservice.KeyboardView.OnKeyboardActionListener |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nListener for virtual keyboard events.\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[onKey](/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#onKey(int,%20int[]))`(int primaryCode, int[] keyCodes) ` Send a key press to the listener. |\n| ` abstract void` | ` `[onPress](/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#onPress(int))`(int primaryCode) ` Called when the user presses a key. |\n| ` abstract void` | ` `[onRelease](/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#onRelease(int))`(int primaryCode) ` Called when the user releases a key. |\n| ` abstract void` | ` `[onText](/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#onText(java.lang.CharSequence))`(`[CharSequence](/reference/java/lang/CharSequence)` text) ` Sends a sequence of characters to the listener. |\n| ` abstract void` | ` `[swipeDown](/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#swipeDown())`() ` Called when the user quickly moves the finger from up to down. |\n| ` abstract void` | ` `[swipeLeft](/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#swipeLeft())`() ` Called when the user quickly moves the finger from right to left. |\n| ` abstract void` | ` `[swipeRight](/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#swipeRight())`() ` Called when the user quickly moves the finger from left to right. |\n| ` abstract void` | ` `[swipeUp](/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#swipeUp())`() ` Called when the user quickly moves the finger from down to up. |\n\nPublic methods\n--------------\n\n### onKey\n\nAdded in [API level 3](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onKey (int primaryCode, \n int[] keyCodes)\n```\n\nSend a key press to the listener.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `primaryCode` | `int`: this is the key that was pressed \u003cbr /\u003e |\n| `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. \u003cbr /\u003e |\n\n### onPress\n\nAdded in [API level 3](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onPress (int primaryCode)\n```\n\nCalled when the user presses a key. This is sent before the [onKey(int, int)](/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#onKey(int,%20int[])) is called.\nFor keys that repeat, this is only called once.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------------|-----------------------------------------------------------------------------------------------------------------|\n| `primaryCode` | `int`: the unicode of the key being pressed. If the touch is not on a valid key, the value will be zero. \u003cbr /\u003e |\n\n### onRelease\n\nAdded in [API level 3](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onRelease (int primaryCode)\n```\n\nCalled when the user releases a key. This is sent after the [onKey(int, int)](/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener#onKey(int,%20int[])) is called.\nFor keys that repeat, this is only called once.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------------|-----------------------------------------------------|\n| `primaryCode` | `int`: the code of the key that was released \u003cbr /\u003e |\n\n### onText\n\nAdded in [API level 3](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onText (CharSequence text)\n```\n\nSends a sequence of characters to the listener.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------|--------------------------------------------------------------------|\n| `text` | `CharSequence`: the sequence of characters to be displayed. \u003cbr /\u003e |\n\n### swipeDown\n\nAdded in [API level 3](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void swipeDown ()\n```\n\nCalled when the user quickly moves the finger from up to down.\n\n\u003cbr /\u003e\n\n### swipeLeft\n\nAdded in [API level 3](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void swipeLeft ()\n```\n\nCalled when the user quickly moves the finger from right to left.\n\n\u003cbr /\u003e\n\n### swipeRight\n\nAdded in [API level 3](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void swipeRight ()\n```\n\nCalled when the user quickly moves the finger from left to right.\n\n\u003cbr /\u003e\n\n### swipeUp\n\nAdded in [API level 3](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void swipeUp ()\n```\n\nCalled when the user quickly moves the finger from down to up.\n\n\u003cbr /\u003e"]]