Added in API level 1

BaseKeyListener

abstract class BaseKeyListener : MetaKeyKeyListener, KeyListener
kotlin.Any
   ↳ android.text.method.MetaKeyKeyListener
   ↳ android.text.method.BaseKeyListener

Abstract base class for key listeners. Provides a basic foundation for entering and editing text. Subclasses should override onKeyDown and #onKeyUp to insert characters as keys are pressed.

As for all implementations of KeyListener, this class is only concerned with hardware keyboards. Software input methods have no obligation to trigger the methods in this class.

Summary

Inherited constants
Public constructors

Public methods
open Boolean
backspace(view: View!, content: Editable!, keyCode: Int, event: KeyEvent!)

Performs the action that happens when you press the KeyEvent#KEYCODE_DEL key in a TextView.

open Boolean
forwardDelete(view: View!, content: Editable!, keyCode: Int, event: KeyEvent!)

Performs the action that happens when you press the KeyEvent#KEYCODE_FORWARD_DEL key in a TextView.

open Boolean
onKeyDown(view: View!, content: Editable!, keyCode: Int, event: KeyEvent!)

open Boolean
onKeyOther(view: View!, content: Editable!, event: KeyEvent!)

Base implementation handles ACTION_MULTIPLE KEYCODE_UNKNOWN by inserting the event's text into the content.

Inherited functions

Public constructors

BaseKeyListener

BaseKeyListener()

Public methods

backspace

Added in API level 1
open fun backspace(
    view: View!,
    content: Editable!,
    keyCode: Int,
    event: KeyEvent!
): Boolean

Performs the action that happens when you press the KeyEvent#KEYCODE_DEL key in a TextView. If there is a selection, deletes the selection; otherwise, deletes the character before the cursor, if any; ALT+DEL deletes everything on the line the cursor is on.

Return
Boolean true if anything was deleted; false otherwise.

forwardDelete

Added in API level 11
open fun forwardDelete(
    view: View!,
    content: Editable!,
    keyCode: Int,
    event: KeyEvent!
): Boolean

Performs the action that happens when you press the KeyEvent#KEYCODE_FORWARD_DEL key in a TextView. If there is a selection, deletes the selection; otherwise, deletes the character before the cursor, if any; ALT+FORWARD_DEL deletes everything on the line the cursor is on.

Return
Boolean true if anything was deleted; false otherwise.

onKeyDown

Added in API level 1
open fun onKeyDown(
    view: View!,
    content: Editable!,
    keyCode: Int,
    event: KeyEvent!
): Boolean

onKeyOther

Added in API level 3
open fun onKeyOther(
    view: View!,
    content: Editable!,
    event: KeyEvent!
): Boolean

Base implementation handles ACTION_MULTIPLE KEYCODE_UNKNOWN by inserting the event's text into the content.