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

# Callback

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/android/view/KeyEvent.Callback "View this page in Java")

```
interface Callback
```

|---|
| [android.view.KeyEvent.Callback](https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback#) |

|---|
| Known Direct Subclasses [AbstractInputMethodService](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.html#), [Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html#), [Dialog](https://developer.android.com/reference/kotlin/android/app/Dialog.html#), [TvAdService.Session](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdService.Session.html#), [TvInputService.Session](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session.html#), [TvInteractiveAppService.Session](https://developer.android.com/reference/kotlin/android/media/tv/interactive/TvInteractiveAppService.Session.html#), [View](https://developer.android.com/reference/kotlin/android/view/View), [VoiceInteractionSession](https://developer.android.com/reference/kotlin/android/service/voice/VoiceInteractionSession.html#) |---|---| | [AbstractInputMethodService](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.html#) | AbstractInputMethodService provides a abstract base class for input methods. | | [Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html#) | An activity is a single, focused thing that the user can do. | | [Dialog](https://developer.android.com/reference/kotlin/android/app/Dialog.html#) | Base class for Dialogs. | | [TvAdService.Session](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdService.Session.html#) | Base class for derived classes to implement to provide a TV AD session. | | [TvInputService.Session](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session.html#) | Base class for derived classes to implement to provide a TV input session. | | [TvInteractiveAppService.Session](https://developer.android.com/reference/kotlin/android/media/tv/interactive/TvInteractiveAppService.Session.html#) | Base class for derived classes to implement to provide a TV interactive app session. | | [View](https://developer.android.com/reference/kotlin/android/view/View) | This class represents the basic building block for user interface components. | | [VoiceInteractionSession](https://developer.android.com/reference/kotlin/android/service/voice/VoiceInteractionSession.html#) | An active voice interaction session, providing a facility for the implementation to interact with the user in the voice interaction layer. | |

|---|
| Known Indirect Subclasses [AbsListView](https://developer.android.com/reference/kotlin/android/widget/AbsListView.html#), [AbsSeekBar](https://developer.android.com/reference/kotlin/android/widget/AbsSeekBar.html#), [AbsSpinner](https://developer.android.com/reference/kotlin/android/widget/AbsSpinner.html#), [AbsoluteLayout](https://developer.android.com/reference/kotlin/android/widget/AbsoluteLayout.html#), [AccountAuthenticatorActivity](https://developer.android.com/reference/kotlin/android/accounts/AccountAuthenticatorActivity.html#), [ActionMenuView](https://developer.android.com/reference/kotlin/android/widget/ActionMenuView.html#), [ActivityGroup](https://developer.android.com/reference/kotlin/android/app/ActivityGroup.html#), [AdapterView](https://developer.android.com/reference/kotlin/android/widget/AdapterView.html#), [AdapterViewAnimator](https://developer.android.com/reference/kotlin/android/widget/AdapterViewAnimator.html#), [AdapterViewFlipper](https://developer.android.com/reference/kotlin/android/widget/AdapterViewFlipper.html#), [AlertDialog](https://developer.android.com/reference/kotlin/android/app/AlertDialog.html#), [AliasActivity](https://developer.android.com/reference/kotlin/android/app/AliasActivity.html#), and 87 others. |---|---| | [AbsListView](https://developer.android.com/reference/kotlin/android/widget/AbsListView.html#) | Base class that can be used to implement virtualized lists of items. | | [AbsSeekBar](https://developer.android.com/reference/kotlin/android/widget/AbsSeekBar.html#) | AbsSeekBar extends the capabilities of ProgressBar by adding a draggable thumb. | | [AbsSpinner](https://developer.android.com/reference/kotlin/android/widget/AbsSpinner.html#) | An abstract base class for spinner widgets. | | [AbsoluteLayout](https://developer.android.com/reference/kotlin/android/widget/AbsoluteLayout.html#) | A layout that lets you specify exact locations (x/y coordinates) of its children. | | [AccountAuthenticatorActivity](https://developer.android.com/reference/kotlin/android/accounts/AccountAuthenticatorActivity.html#) | Base class for implementing an Activity that is used to help implement an AbstractAccountAuthenticator. | | [ActionMenuView](https://developer.android.com/reference/kotlin/android/widget/ActionMenuView.html#) | ActionMenuView is a presentation of a series of menu options as a View. | | [ActivityGroup](https://developer.android.com/reference/kotlin/android/app/ActivityGroup.html#) | A screen that contains and runs multiple embedded activities. | | [AdapterView](https://developer.android.com/reference/kotlin/android/widget/AdapterView.html#) | An AdapterView is a view whose children are determined by an `https://developer.android.com/reference/kotlin/android/widget/Adapter.html#`. | | [AdapterViewAnimator](https://developer.android.com/reference/kotlin/android/widget/AdapterViewAnimator.html#) | Base class for a `https://developer.android.com/reference/kotlin/android/widget/AdapterView.html#` that will perform animations when switching between its views. | | [AdapterViewFlipper](https://developer.android.com/reference/kotlin/android/widget/AdapterViewFlipper.html#) | Simple `https://developer.android.com/reference/kotlin/android/widget/ViewAnimator.html#` that will animate between two or more views that have been added to it. | | [AlertDialog](https://developer.android.com/reference/kotlin/android/app/AlertDialog.html#) | A subclass of Dialog that can display one, two or three buttons. | | [AliasActivity](https://developer.android.com/reference/kotlin/android/app/AliasActivity.html#) | Stub activity that launches another activity (and then finishes itself) based on information in its component's manifest meta-data. | | [AnalogClock](https://developer.android.com/reference/kotlin/android/widget/AnalogClock.html#) | This widget displays an analogic clock with two hands for hours and minutes. | | [AppWidgetHostView](https://developer.android.com/reference/kotlin/android/appwidget/AppWidgetHostView.html#) | Provides the glue to show AppWidget views. | | [AutoCompleteTextView](https://developer.android.com/reference/kotlin/android/widget/AutoCompleteTextView.html#) | An editable text view that shows completion suggestions automatically while the user is typing. | | [Button](https://developer.android.com/reference/kotlin/android/widget/Button.html#) | A user interface element the user can tap or click to perform an action. | | [CalendarView](https://developer.android.com/reference/kotlin/android/widget/CalendarView.html#) | This class is a calendar widget for displaying and selecting dates. | | [CharacterPickerDialog](https://developer.android.com/reference/kotlin/android/text/method/CharacterPickerDialog.html#) | Dialog for choosing accented characters related to a base character. | | [CheckBox](https://developer.android.com/reference/kotlin/android/widget/CheckBox.html#) | A checkbox is a specific type of two-states button that can be either checked or unchecked. | | [CheckedTextView](https://developer.android.com/reference/kotlin/android/widget/CheckedTextView.html#) | An extension to `https://developer.android.com/reference/kotlin/android/widget/TextView.html#` that supports the `https://developer.android.com/reference/kotlin/android/widget/Checkable.html#` interface and displays. | | [Chronometer](https://developer.android.com/reference/kotlin/android/widget/Chronometer.html#) | Class that implements a simple timer. | | [CompoundButton](https://developer.android.com/reference/kotlin/android/widget/CompoundButton.html#) | A button with two states, checked and unchecked. | | [DatePicker](https://developer.android.com/reference/kotlin/android/widget/DatePicker.html#) | Provides a widget for selecting a date. | | [DatePickerDialog](https://developer.android.com/reference/kotlin/android/app/DatePickerDialog.html#) | A simple dialog containing an `https://developer.android.com/reference/kotlin/android/widget/DatePicker.html#`. | | [DialerFilter](https://developer.android.com/reference/kotlin/android/widget/DialerFilter.html#) | This widget is a layout that contains several specifically-named child views that handle keyboard entry interpreted as standard phone dialpad digits. | | [DigitalClock](https://developer.android.com/reference/kotlin/android/widget/DigitalClock.html#) | Like AnalogClock, but digital. | | [EditText](https://developer.android.com/reference/kotlin/android/widget/EditText.html#) | A user interface element for entering and modifying text. | | [ExpandableListActivity](https://developer.android.com/reference/kotlin/android/app/ExpandableListActivity.html#) | An activity that displays an expandable list of items by binding to a data source implementing the ExpandableListAdapter, and exposes event handlers when the user selects an item. | | [ExpandableListView](https://developer.android.com/reference/kotlin/android/widget/ExpandableListView.html#) | A view that shows items in a vertically scrolling two-level list. | | [ExtractEditText](https://developer.android.com/reference/kotlin/android/inputmethodservice/ExtractEditText.html#) | \* Specialization of `https://developer.android.com/reference/kotlin/android/widget/EditText.html#` for showing and interacting with the extracted text in a full-screen input method. | | [FragmentBreadCrumbs](https://developer.android.com/reference/kotlin/android/app/FragmentBreadCrumbs.html#) | Helper class for showing "bread crumbs" representing the fragment stack in an activity. | | [FrameLayout](https://developer.android.com/reference/kotlin/android/widget/FrameLayout.html#) | FrameLayout is designed to block out an area on the screen to display a single item. | | [GLSurfaceView](https://developer.android.com/reference/kotlin/android/opengl/GLSurfaceView.html#) | An implementation of SurfaceView that uses the dedicated surface for displaying OpenGL rendering. | | [Gallery](https://developer.android.com/reference/kotlin/android/widget/Gallery.html#) | A view that shows items in a center-locked, horizontally scrolling list. | | [GestureOverlayView](https://developer.android.com/reference/kotlin/android/gesture/GestureOverlayView.html#) | A transparent overlay for gesture input that can be placed on top of other widgets or contain other widgets. | | [GridLayout](https://developer.android.com/reference/kotlin/android/widget/GridLayout.html#) | A layout that places its children in a rectangular *grid*. | | [GridView](https://developer.android.com/reference/kotlin/android/widget/GridView.html#) | A view that shows items in two-dimensional scrolling grid. | | [HorizontalScrollView](https://developer.android.com/reference/kotlin/android/widget/HorizontalScrollView.html#) | Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. | | [ImageButton](https://developer.android.com/reference/kotlin/android/widget/ImageButton.html#) | Displays a button with an image (instead of text) that can be pressed or clicked by the user. | | [ImageSwitcher](https://developer.android.com/reference/kotlin/android/widget/ImageSwitcher.html#) | `https://developer.android.com/reference/kotlin/android/widget/ViewSwitcher.html#` that switches between two ImageViews when a new image is set on it. | | [ImageView](https://developer.android.com/reference/kotlin/android/widget/ImageView.html#) | Displays image resources, for example `https://developer.android.com/reference/kotlin/android/graphics/Bitmap.html#` or `https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.html#` resources. | | [InlineContentView](https://developer.android.com/reference/kotlin/android/widget/inline/InlineContentView.html#) | This class represents a view that holds opaque content from another app that you can inline in your UI. | | [InputMethodService](https://developer.android.com/reference/kotlin/android/inputmethodservice/InputMethodService.html#) | InputMethodService provides a standard implementation of an InputMethod, which final implementations can derive from and customize. | | [KeyboardView](https://developer.android.com/reference/kotlin/android/inputmethodservice/KeyboardView.html#) | A view that renders a virtual `https://developer.android.com/reference/kotlin/android/inputmethodservice/Keyboard.html#`. | | [LauncherActivity](https://developer.android.com/reference/kotlin/android/app/LauncherActivity.html#) | Displays a list of all activities which can be performed for a given intent. | | [LinearLayout](https://developer.android.com/reference/kotlin/android/widget/LinearLayout.html#) | A layout that arranges other views either horizontally in a single column or vertically in a single row. | | [ListActivity](https://developer.android.com/reference/kotlin/android/app/ListActivity.html#) | An activity that displays a list of items by binding to a data source such as an array or Cursor, and exposes event handlers when the user selects an item. | | [ListView](https://developer.android.com/reference/kotlin/android/widget/ListView.html#) | Displays a vertically-scrollable collection of views, where each view is positioned immediately below the previous view in the list. | | [MediaController](https://developer.android.com/reference/kotlin/android/widget/MediaController.html#) | A view containing controls for a MediaPlayer. | | [MediaRouteButton](https://developer.android.com/reference/kotlin/android/app/MediaRouteButton.html#) | <br /> | | [MultiAutoCompleteTextView](https://developer.android.com/reference/kotlin/android/widget/MultiAutoCompleteTextView.html#) | An editable text view, extending `https://developer.android.com/reference/kotlin/android/widget/AutoCompleteTextView.html#`, that can show completion suggestions for the substring of the text where the user is typing instead of necessarily for the entire thing. | | [NativeActivity](https://developer.android.com/reference/kotlin/android/app/NativeActivity.html#) | Convenience for implementing an activity that will be implemented purely in native code. | | [NumberPicker](https://developer.android.com/reference/kotlin/android/widget/NumberPicker.html#) | A widget that enables the user to select a number from a predefined range. | | [PreferenceActivity](https://developer.android.com/reference/kotlin/android/preference/PreferenceActivity.html#) | This is the base class for an activity to show a hierarchy of preferences to the user. | | [Presentation](https://developer.android.com/reference/kotlin/android/app/Presentation.html#) | Base class for presentations. | | [ProgressBar](https://developer.android.com/reference/kotlin/android/widget/ProgressBar.html#) | A user interface element that indicates the progress of an operation. | | [ProgressDialog](https://developer.android.com/reference/kotlin/android/app/ProgressDialog.html#) | A dialog showing a progress indicator and an optional text message or view. | | [QuickContactBadge](https://developer.android.com/reference/kotlin/android/widget/QuickContactBadge.html#) | Widget used to show an image with the standard QuickContact badge and on-click behavior. | | [RadioButton](https://developer.android.com/reference/kotlin/android/widget/RadioButton.html#) | A radio button is a two-states button that can be either checked or unchecked. | | [RadioGroup](https://developer.android.com/reference/kotlin/android/widget/RadioGroup.html#) | This class is used to create a multiple-exclusion scope for a set of radio buttons. | | [RatingBar](https://developer.android.com/reference/kotlin/android/widget/RatingBar.html#) | A RatingBar is an extension of SeekBar and ProgressBar that shows a rating in stars. | | [RelativeLayout](https://developer.android.com/reference/kotlin/android/widget/RelativeLayout.html#) | A Layout where the positions of the children can be described in relation to each other or to the parent. | | [ScrollView](https://developer.android.com/reference/kotlin/android/widget/ScrollView.html#) | A view group that allows the view hierarchy placed within it to be scrolled. | | [SearchView](https://developer.android.com/reference/kotlin/android/widget/SearchView.html#) | A widget that provides a user interface for the user to enter a search query and submit a request to a search provider. | | [SeekBar](https://developer.android.com/reference/kotlin/android/widget/SeekBar.html#) | A SeekBar is an extension of ProgressBar that adds a draggable thumb. | | [SlidingDrawer](https://developer.android.com/reference/kotlin/android/widget/SlidingDrawer.html#) | SlidingDrawer hides content out of the screen and allows the user to drag a handle to bring the content on screen. | | [Space](https://developer.android.com/reference/kotlin/android/widget/Space.html#) | Space is a lightweight View subclass that may be used to create gaps between components in general purpose layouts. | | [Spinner](https://developer.android.com/reference/kotlin/android/widget/Spinner.html#) | A view that displays one child at a time and lets the user pick among them. | | [SplashScreenView](https://developer.android.com/reference/kotlin/android/window/SplashScreenView.html#) | The view which allows an activity to customize its splash screen exit animation. | | [StackView](https://developer.android.com/reference/kotlin/android/widget/StackView.html#) | <br /> | | [SurfaceView](https://developer.android.com/reference/kotlin/android/view/SurfaceView) | Provides a dedicated drawing surface embedded inside of a view hierarchy. | | [Switch](https://developer.android.com/reference/kotlin/android/widget/Switch.html#) | A Switch is a two-state toggle widget. | | [TabActivity](https://developer.android.com/reference/kotlin/android/app/TabActivity.html#) | For apps developing against `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#HONEYCOMB:kotlin.Int` or later, tabs are typically presented in the UI using the new `https://developer.android.com/reference/kotlin/android/app/ActionBar.html#newTab()` and related APIs for placing tabs within their action bar area. | | [TabHost](https://developer.android.com/reference/kotlin/android/widget/TabHost.html#) | Container for a tabbed window view. | | [TabWidget](https://developer.android.com/reference/kotlin/android/widget/TabWidget.html#) | Displays a list of tab labels representing each page in the parent's tab collection. | | [TableLayout](https://developer.android.com/reference/kotlin/android/widget/TableLayout.html#) | A layout that arranges its children into rows and columns. | | [TableRow](https://developer.android.com/reference/kotlin/android/widget/TableRow.html#) | A layout that arranges its children horizontally. | | [TextClock](https://developer.android.com/reference/kotlin/android/widget/TextClock.html#) | `TextClock` can display the current date and/or time as a formatted string. | | [TextSwitcher](https://developer.android.com/reference/kotlin/android/widget/TextSwitcher.html#) | Specialized `https://developer.android.com/reference/kotlin/android/widget/ViewSwitcher.html#` that contains only children of type `https://developer.android.com/reference/kotlin/android/widget/TextView.html#`. | | [TextView](https://developer.android.com/reference/kotlin/android/widget/TextView.html#) | A user interface element that displays text to the user. | | [TextureView](https://developer.android.com/reference/kotlin/android/view/TextureView) | A TextureView can be used to display a content stream, such as that coming from a camera preview, a video, or an OpenGL scene. | | [TimePicker](https://developer.android.com/reference/kotlin/android/widget/TimePicker.html#) | A widget for selecting the time of day, in either 24-hour or AM/PM mode. | | [TimePickerDialog](https://developer.android.com/reference/kotlin/android/app/TimePickerDialog.html#) | A dialog that prompts the user for the time of day using a `https://developer.android.com/reference/kotlin/android/widget/TimePicker.html#`. | | [ToggleButton](https://developer.android.com/reference/kotlin/android/widget/ToggleButton.html#) | Displays checked/unchecked states as a button with a "light" indicator and by default accompanied with the text "ON" or "OFF". | | [Toolbar](https://developer.android.com/reference/kotlin/android/widget/Toolbar.html#) | A standard toolbar for use within application content. | | [TvAdView](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdView.html#) | Displays contents of TV advertisement services. | | [TvInputService.HardwareSession](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.HardwareSession.html#) | Base class for a TV input session which represents an external device connected to a hardware TV input. | | [TvInteractiveAppView](https://developer.android.com/reference/kotlin/android/media/tv/interactive/TvInteractiveAppView.html#) | Displays contents of interactive TV applications. | | [TvView](https://developer.android.com/reference/kotlin/android/media/tv/TvView.html#) | Displays TV contents. | | [TwoLineListItem](https://developer.android.com/reference/kotlin/android/widget/TwoLineListItem.html#) | A view group with two children, intended for use in ListViews. | | [VideoView](https://developer.android.com/reference/kotlin/android/widget/VideoView.html#) | Displays a video file. | | [ViewAnimator](https://developer.android.com/reference/kotlin/android/widget/ViewAnimator.html#) | Base class for a `https://developer.android.com/reference/kotlin/android/widget/FrameLayout.html#` container that will perform animations when switching between its views. | | [ViewFlipper](https://developer.android.com/reference/kotlin/android/widget/ViewFlipper.html#) | Simple `https://developer.android.com/reference/kotlin/android/widget/ViewAnimator.html#` that will animate between two or more views that have been added to it. | | [ViewGroup](https://developer.android.com/reference/kotlin/android/view/ViewGroup) | A `ViewGroup` is a special view that can contain other views (called children.) The view group is the base class for layouts and views containers. | | [ViewStub](https://developer.android.com/reference/kotlin/android/view/ViewStub) | A ViewStub is an invisible, zero-sized View that can be used to lazily inflate layout resources at runtime. | | [ViewSwitcher](https://developer.android.com/reference/kotlin/android/widget/ViewSwitcher.html#) | `https://developer.android.com/reference/kotlin/android/widget/ViewAnimator.html#` that switches between two views, and has a factory from which these views are created. | | [WebView](https://developer.android.com/reference/kotlin/android/webkit/WebView.html#) | A View that displays web pages. | | [ZoomButton](https://developer.android.com/reference/kotlin/android/widget/ZoomButton.html#) | This widget provides a simple utility for turning a continued long-press event into a series of clicks at some set frequency. | | [ZoomControls](https://developer.android.com/reference/kotlin/android/widget/ZoomControls.html#) | The `ZoomControls` class displays a simple set of controls used for zooming and provides callbacks to register for events. | |

## Summary

| Public methods ||
|---|---|
| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback#onKeyDown(kotlin.Int,%20android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/kotlin/android/view/KeyEvent!)` Called when a key down event has occurred. |
| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback#onKeyLongPress(kotlin.Int,%20android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/kotlin/android/view/KeyEvent!)` Called when a long press has occurred. |
| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback#onKeyMultiple(kotlin.Int,%20kotlin.Int,%20android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, count: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/kotlin/android/view/KeyEvent!)` Called when a user's interaction with an analog control, such as flinging a trackball, generates simulated down/up events for the same key multiple times in quick succession. |
| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback#onKeyUp(kotlin.Int,%20android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/kotlin/android/view/KeyEvent!)` Called when a key up event has occurred. |

## Public methods

### onKeyDown

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

```
abstract fun onKeyDown(
    keyCode: Int, 
    event: KeyEvent!
): Boolean
```

Called when a key down event has occurred. If you return true, you can first call `https://developer.android.com/reference/kotlin/android/view/KeyEvent#startTracking()` to have the framework track the event through its `https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback#onKeyUp(kotlin.Int,%20android.view.KeyEvent)` and also call your `https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback#onKeyLongPress(kotlin.Int,%20android.view.KeyEvent)` if it occurs.

| Parameters ||
|---|---|
| `keyCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The value in event.getKeyCode(). |
| `event` | [KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent)!: Description of the key event. |

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. |

### onKeyLongPress

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

```
abstract fun onKeyLongPress(
    keyCode: Int, 
    event: KeyEvent!
): Boolean
```

Called when a long press has occurred. If you return true, the final key up will have `https://developer.android.com/reference/kotlin/android/view/KeyEvent#FLAG_CANCELED:kotlin.Int` and `https://developer.android.com/reference/kotlin/android/view/KeyEvent#FLAG_CANCELED_LONG_PRESS:kotlin.Int` set. Note that in order to receive this callback, someone in the event change *must* return true from `https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback#onKeyDown(kotlin.Int,%20android.view.KeyEvent)` *and* call `https://developer.android.com/reference/kotlin/android/view/KeyEvent#startTracking()` on the event.

| Parameters ||
|---|---|
| `keyCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The value in event.getKeyCode(). |
| `event` | [KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent)!: Description of the key event. |

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. |

### onKeyMultiple

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

```
abstract fun onKeyMultiple(
    keyCode: Int, 
    count: Int, 
    event: KeyEvent!
): Boolean
```

Called when a user's interaction with an analog control, such as flinging a trackball, generates simulated down/up events for the same key multiple times in quick succession.

| Parameters ||
|---|---|
| `keyCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The value in event.getKeyCode(). |
| `count` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Number of pairs as returned by event.getRepeatCount(). |
| `event` | [KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent)!: Description of the key event. |

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. |

### onKeyUp

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

```
abstract fun onKeyUp(
    keyCode: Int, 
    event: KeyEvent!
): Boolean
```

Called when a key up event has occurred.

| Parameters ||
|---|---|
| `keyCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The value in event.getKeyCode(). |
| `event` | [KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent)!: Description of the key event. |

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. |